Instagramm API PHP Follow User

萝らか妹 提交于 2021-01-28 21:32:24

问题


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

}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:


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.



来源:https://stackoverflow.com/questions/31307719/instagramm-api-php-follow-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!