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!!!