Jason
Jason

Reputation: 4957

What is the simplest way to display Instagram follower count

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.

Upvotes: 6

Views: 9639

Answers (1)

Matheus Veloza
Matheus Veloza

Reputation: 502

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;

Upvotes: 4

Related Questions