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?

398

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:

$url = 'https://api.instagram.com/v1/users/280766222/media/recent/?access_token=$token';

You will have to retrieve this token first via the oAuth authentication flow as described in the Instagram API docs.

76

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

People are also looking for solutions to the problem: javascript - PHP Ajax code unable to update database

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.