0
我使用下面從FB檢索評論:無效參數
$url = urlencode("http://*****.com/pages/view?id=2153&item=Mens-Collection-Shoes");
$request_url ="https://graph.facebook.com/comments/?ids=" . $url;
$requests = file_get_contents($request_url);
當我print_r($requests);
我得到以下但不知道如何將它與foreach循環格式:
{
"http:\/\/*****.com\/pages\/view?id=2153&item=Mens-Collection-Shoes": {
"comments": {
"data": [{
"id": "123456",
"from": {
"name": "Laurelle",
"id": "123456"
},
"message": "I love these",
"can_remove": false,
"created_time": "2012-11-20T10:20:16+0000",
"like_count": 0,
"user_likes": false
} {
"id": "123456",
"from": {
"name": "Dan",
"id": "123456"
},
"message": "I know, just stunning!",
"can_remove": false,
"created_time": "2012-11-20T14:24:15+0000",
"like_count": 0,
"user_likes": false
}],
"paging": {
"next": "https:\/\/graph.facebook.com\/*****\/comments?limit=25&offset=25&__after_id=*****"
}
}
}
}
我試圖讓:
data->from->id
data->from->name
data->message
data->created_time
我已經試過:
$fb_response = json_decode($requests);
foreach($fb_response->data as $item){
echo $item->from->id . '<br />';
echo $item->from->name . '<br />';
echo $item->message . '<br />';
echo $item->created_time . '<br /><br />';
}
,但沒有運氣
有你'json_decode()'語句後檢查'$ fb_response'的價值? –
我敢打賭,他沒有,因爲他要求完全一樣的問題,前面我說同樣的事情 – Dale
@Dale我曾嘗試你在最後發表的帖子說,但關閉它,因爲它是寫在一個混亂的方式,我故障 - 你可以從下面的回答看,你的回答並沒有解決我有問題,但是,我很欣賞的答覆。 –