Reputation: 453
From the following graph api url,
$graphURL = "https://graph.facebook.com/me/news.reads&access_token=$access_token?" .
//"callback=''&" .
"date_format=U&" .
"limit=5";
I get an array result in the following format:
{"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}},
... How do I extract the article title from this multidim array?
Upvotes: 1
Views: 1236
Reputation: 20860
Parse the output as json.
$d = json_decode($data,true); // Here $data is the output returned from facebook API
print_r($d['data'][0]['data']['article']);
Output will be :
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
)
Upvotes: 1
Reputation: 43816
Parse it as JSON and extract the fields you need like with any other array
Upvotes: 0