duanmu2013 2015-07-09 03:40
浏览 119
已采纳

Instagram API PHP关注用户

at the Moment i try to implent the Instagramm API in a Website. Which is able to get Access Token and then follow a User.

I searched Google but i wasnt able to find a usefull code Example for PHP ?

Only thing i found was this https://github.com/cosenary/Instagram-PHP-API


Now i coded this one here

   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(), "
";
}

}else {

        $urli= $instagram->getLoginUrl(array(
    'basic',
    'relationships',
    'likes'
));


    echo "<a href=".$urli.">Login with Instagram</a>";

}

But it isnt working... There is no Error Message or something else but it isnt following the User.

So now my Questions:

Does someone know why ? ... Or does anyone know the right way to get this working ?

Please with Links and Code Examples.

That Would be Grape
Thanks!!!

  • 写回答

1条回答 默认 最新

  • dtxw20878 2015-07-09 03:53
    关注

    You can follow the URL for instagramm API. I use this for instagram login and its work for me

    but you can also check for follow a User & Relationship but I think it will work for you as well.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?