Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the simplest way to display Instagram follower count

Tags:

api

instagram

I am using WordPress and trying to figure out the simplest way to display the amount of Instagram followers a user has.

Whilst searching I have found a few Instagram PHP wrapper scripts that seem a little overkill for what I am trying to display.

From reading through the Stackoverflow posts I came across a post that listed this code:

$userinfo = wp_remote_get("https://api.instagram.com/v1/users/3955450?access_token=f0d225aa955c4bd9ae563f87f831efab");
$userinfo = json_decode($userinfo);

$followers = $userinfo['data']['counts']['followed_by'];

echo "Folled by: " . $followers . " people";

This is a simple and perfect script HOWEVER it does not return any data.

I have setup a client on the Instagram Developer site however I cannot get the above script to display any data.

Any help would be greatly appreciated.

like image 222
Jason Avatar asked Oct 21 '22 15:10

Jason


1 Answers

Try this:

$result = file_get_contents("https://api.instagram.com/v1/users/3955450?access_token=f0d225aa955c4bd9ae563f87f831efab");
$obj = json_decode($result);
echo $obj->data[0]->id;
like image 71
Matheus Veloza Avatar answered Oct 25 '22 17:10

Matheus Veloza