php - Instagram API $data returning NULL
422
I am trying to display my instagram followers counts in a custom PHP file.
I am trying this code:
<?php
$url = 'https://api.instagram.com/v1/users/280766222/media/recent/?access_token=$token';
$content = file_get_contents($url);
$data = json_decode($content, true);
var_dump($data['data']);
?>
It only returnsNULL
.
What should I do?
Answer
Solution:
I am not sure if
$token
is just a placeholder to hide sensitive information, but if not, you have to pass your personal access token via the URL instead of$token
:You will have to retrieve this token first via the oAuth authentication flow as described in the Instagram API docs.
Answer
Solution:
do you have authorize your access token scope?? if no, you must activate the authorize here : https://api.instagram.com/oauth/authorize/?client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&response_type=token&scope=follower_list