-1

Using this code I can get the ID fine, but I can't figure out how to get the integer part of the array, for example the follows value:

$result = file_get_contents("https://api.instagram.com/v1/users/1234/?access_token={TOKEN}");
$obj = json_decode($result);
echo $obj->data->id;

INSTAGRAM JSON EXAMPLE:

object(stdClass)#1 (2) { ["meta"]=> object(stdClass)#2 (1) { ["code"]=> int(200) } ["data"]=> object(stdClass)#3 (7) { ["username"]=> string(6) "TESTY" ["bio"]=> string(51) "BLAH BLAH" ["website"]=> string(26) "http://domain.com" ["profile_picture"]=> string(110) "https://scontent.cdninstagram.com/hphotos-xfa1/some.jpg" ["full_name"]=> string(16) "MY TESTY" ["counts"]=> object(stdClass)#4 (3) { ["media"]=> int(141) ["followed_by"]=> int(23900) ["follows"]=> int(184) } ["id"]=> string(4) "1234" } }

How do I construct this line to get the follows integer value?

echo $obj->data->follows;
kittykittybangbang
  • 2,380
  • 4
  • 16
  • 27
Jamie
  • 371
  • 3
  • 17

1 Answers1

1
echo $obj->data->counts->follows;
Andrejs Cainikovs
  • 27,428
  • 2
  • 75
  • 95
Joe Horn
  • 445
  • 3
  • 13