1

从以下图形 api url,

$graphURL = "https://graph.facebook.com/me/news.reads&access_token=$access_token?" .
//"callback=''&" .
"date_format=U&" . 
"limit=5";

我得到以下格式的数组结果:

{"data":[{"id":"10151079746224166",
"from":{"name":"Nicholas Billionea","id":"666859165"},
"start_time":1344853875,
"end_time":1344853875,
"publish_time":1344853875,
"application":{"name":"Muzikki","namespace":"muzikki","id":"354957834546710"},
"data":{"article":{"id":"10150987952714331",
"url":"http:\/\/muzikki.com\/articles\/headlines\/mustapha-qtac-become-ambassadors-for-gui\/",
"type":"article",
"title":"Mustapha, Q-Tac become ambassadors for Guiness campaign in kenya"}},
"type":"news.reads",
"no_feed_story":false,
"likes":{"count":0,"can_like":true,"user_likes":false},
"comments":{"count":0,"can_comment":true}},

...如何从这个 multidim 数组中提取文章标题?

4

2 回答 2

1

将输出解析为 json。

$d = json_decode($data,true); // Here $data is the output returned from facebook API
print_r($d['data'][0]['data']['article']);

输出将是:

Array
(
    [id] => 10150987952714331
    [url] => http://muzikki.com/articles/headlines/mustapha-qtac-become-ambassadors-for-gui/
    [type] => article
    [title] => Mustapha, Q-Tac become ambassadors for Guiness campaign in kenya
)
于 2013-09-18T10:55:06.137 回答
0

将其解析为 JSON 并像使用任何其他数组一样提取您需要的字段

于 2012-08-17T14:22:16.440 回答