i Want to fetch this data using json decode. Please Help..
So far i come up with this script but i unable to fetch the second last and last ‘name’ and ‘link’ under actions. please help..
foreach($json['data'] as $post)
{
$name1 = $post['actions']['name'];
$name2 = $post['actions']['name']['name'];
$name3 = $post['actions']['name']['name']['name'];
But this is not working please help i want to get all name and link data from following example its a snippet from facebook graph api..
{ "data": [ { "actions": [ { "name": "Comment", "link": "http://www.facebook.com/xxxxxidxxxx/posts/xxxxidxxxxxx" }, { "name": "Like", "link": "http://www.facebook.com/xxxxxidxxxxxx/posts/xxxxidxxxxxxx" } { "name": "Comment", "link": "http://www.facebook.com/xxxxxidxxxx/posts/xxxxidxxxxxx" }, { "name": "Like", "link": "http://www.facebook.com/xxxxxidxxxxxx/posts/xxxxidxxxxxxx" } { "name": "Comment", "link": "http://www.facebook.com/xxxxxidxxxx/posts/xxxxidxxxxxx" }, { "name": "Like", "link": "http://www.facebook.com/xxxxxidxxxxxx/posts/xxxxidxxxxxxx" } ],
Please note that
actionsis an array and it’s the only member ofdatain your case.You just iterating over wrong part, the code should be: