【发布时间】:2015-09-27 06:02:55
【问题描述】:
目前我尝试在网站中实现 Instagramm API。 哪个能够获取访问令牌然后关注用户。
我在 Google 上搜索过,但找不到有用的 PHP 代码示例?
我发现的只有这个 https://github.com/cosenary/Instagram-PHP-API
现在我在这里编码了这个
error_reporting(E_ALL);
ini_set("display_errors", 1);
require 'inc/Instagram.php';
require 'inc/InstagramException.php';
use MetzWeb\Instagram\Instagram;
$instagram = new Instagram(array(
'apiKey' => 'APIKEY',
'apiSecret' => 'SECRET',
'apiCallback' => 'CALLBACK'
));
if (isset($_GET['code'])) {
// grab OAuth callback code
$code = $_GET['code'];
$data = $instagram->getOAuthToken($code);
echo 'Your username is: ' . $data->user->username;
$token= $data->access_token;
$instagram->setAccessToken($token);
echo $instagram->getAccessToken();
try {
$instagram->modifyRelationship('follow', 1399448929);
} catch (Exception $e) {
echo 'Exception abgefangen: ', $e->getMessage(), "\n";
}
}else {
$urli= $instagram->getLoginUrl(array(
'basic',
'relationships',
'likes'
));
echo "<a href=".$urli.">Login with Instagram</a>";
}
但它不起作用... 没有错误消息或其他内容,但它没有跟随用户。
所以现在我的问题:
有人知道为什么吗? ... 或者有谁知道让这个工作的正确方法?
请提供链接和代码示例。
那是葡萄
谢谢!!!
【问题讨论】: