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.

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

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失