使用此代码我可以很好地获取ID,但我无法弄清楚如何获取数组的整数部分,例如follows
值:
$result = file_get_contents("https://api.instagram.com/v1/users/1234/?access_token={TOKEN}");
$obj = json_decode($result);
echo $obj->data->id;
INSTAGRAM JSON示例:
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" } }
如何构造此行以使跟随整数值?
echo $obj->data->follows;
答案 0 :(得分:1)
echo $obj->data->counts->follows;