Bonjour.

Je développe un petit client maison pour Instagram en utilisant l'API Instagram et la classe ** galen/PHP-Instagram-API** https://github.com/galen/PHP-Instagram-API

J'essaye d'acquérir les droit de "relationships" avec l'API instagram ce qui me permetrait de Follow et unfollow un user instagram.

Quand j'effectue :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
 
session_start();
 
require "vendor/autoload.php";
 
$auth = new Instagram\Auth([
    'client_id'     => '4be2e6fbedfc4f55abbe1faabdd2448a',
    'client_secret' => 'f396c745a0414b87953ae834c6038e32',
    'redirect_uri'  => 'http://127.0.0.1/',
    'scope'         => array( 'likes', 'comments','relationships' )
]);
 
 
if(!isset($_SESSION['instagram_token'])){
    if(!isset($_GET['code'])){
        $auth->authorize();
    } else {
        $access_token = $auth->getAccessToken($_GET['code']);
        $_SESSION['instagram_token'] = $access_token;
    }
}
 
$instagram = new Instagram\Instagram;
$instagram->setAccessToken( $_SESSION['instagram_token'] ); 
$current_user = $instagram->getCurrentUser(); 
$user = $instagram->getUser('260054703'); 
$current_user->follow($user);
Le résultat est :

Fatal error: Uncaught exception 'Instagram\Core\ApiException' with message 'This request requires scope=relationships, but this access token is not authorized with this scope. The user must re-authorize your application with scope=relationships to be granted write permissions.' in /var/www/vendor/php-instagram-api/php-instagram-api/Instagram/Core/Proxy.php:553 Stack trace: #0 /var/www/vendor/php-instagram-api/php-instagram-api/Instagram/Core/Proxy.php(461): Instagram\Core\Proxy->apiCall('post', 'https://api.ins...', Array) #1 /var/www/vendor/php-instagram-api/php-instagram-api/Instagram/CurrentUser.php(176): Instagram\Core\Proxy->modifyRelationship('260054703', 'follow') #2 /var/www/index2.php(28): Instagram\CurrentUser->follow(Object(Instagram\User)) #3 {main} thrown in /var/www/vendor/php-instagram-api/php-instagram-api/Instagram/Core/Proxy.php on line 553
Donc j'en déduis que mon TOKEN n'a pas les droits relationships et n'est donc pas autorisé à effectuer cette action.

Alors pour vérifier je recommence en m'aidant de la DOC de l'API INSTAGRAM

https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=code
(en prenant soin de remplacer CLIENT-ID REDIRECT-URI et en rajoutant comme énoncer plus bas dans la doc le champ SCOPE avec pour valeur likes+comments+relationships

Voici le résultat

Nom : Capture d’écran 2015-06-17 à 18.11.04.png
Affichages : 539
Taille : 516,4 Ko

Access your basic information Donc ma demande de droits relationships, likes et comments n'est pas passé.

Pourquoi ??? :'(

Merci d'avance