我已向Instagram API请求了一位用户关注者列表。预期的回报就是这个..
{
"data": [{
"username": "kevin",
"profile_picture": "http://images.ak.instagram.com/profiles/profile_3_75sq_1325536697.jpg",
"full_name": "Kevin Systrom",
"id": "3"
},
{
"username": "instagram",
"profile_picture": "http://images.ak.instagram.com/profiles/profile_25025320_75sq_1340929272.jpg",
"full_name": "Instagram",
"id": "25025320"
}]
我已经尝试过使用它,但它不起作用!!
foreach ($followerList['data'] as $follower) {
echo $follower['full_name'], '<br>';
}
我无法看到我在生活中出错的地方,任何想法?谢谢
编辑:$ followerList已经被解码,由于&#34;数据&#34;我正在努力访问数组。在预期的产出中。我不确定如何通过&#34;数据&#34;来访问数组。然后才能访问元素!
答案 0 :(得分:0)
因为该响应是JSON,PHP只是将其视为字符串。你需要解码它:
$followerList = json_decode($followerList, true);
然后您可以作为数组访问$followerList
。
此外,您的JSON似乎缺少结尾}
。