我正在使用代码点火器,在我的视图文件中
<?php
$app_id = "APP_ID_HERE_XXXXXXXX";
$secret = "SECRET_XXXXXXXX";
$data = file_get_contents('https://graph.facebook.com/me?fields=friends&access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
$data = json_decode($data);
}
?>
问题:如何从JSON数据打印好友列表
像这样解码后的文件数据:
stdClass Object
(
[friends] => stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[name] => frnd_name
[id] => frnd_id
)
[1] => stdClass Object
(
[name] => frnd_name
[id] => frnd_id
)
[2] => stdClass Object
(
[name] => frnd_name
[id] => frnd_id
)....
如何在列表项中打印frnds名称。。Thanx
试试这个:
foreach($data->friends->data as $friend){
echo $friend->name." ".$friend->id."<br/>";
}