0

I have a working api call to get basic user info and I am trying to return just the "followed_by" portion of the json data from "counts". This link should return just the json page on your browser

https://api.instagram.com/v1/users/self/?access_token=3514554632.a691e29.3f773f5f335a4ba98fc9609d1d405fb0

And here is my code to try and parse the result, but all I am getting is a blank screen.

$jsondata = file_get_contents("https://api.instagram.com/v1/users/self/?access_token=3514554632.a691e29.3f773f5f335a4ba98fc9609d1d405fb0");
$json = json_decode($jsondata, true);
$json2 = json_decode($jsondata);
//method one to parse, not working
$parsedvalue = $json['counts'][1]['followed_by'];
echo $parsedvalue;

//method two to parse, not working
$followercount = $json2->counts->followed_by;
echo $followercount;
Manik Khurana
  • 39
  • 1
  • 10

1 Answers1

0

Here is the fix I got figured out for //method 2

$jsondata = file_get_contents("https://api.instagram.com/v1/users/self/?access_token=3514554632.a691e29.3f773f5f335a4ba98fc9609d1d405fb0");
$json2 = json_decode($jsondata);

$followercount = $json2->data->counts->followed_by;

This properly returns your follower count, but I still need help understanding how to fix method one

Manik Khurana
  • 39
  • 1
  • 10