For each loop Facebook graph api -


i'm trying make each loop on field name of user like. problem errors or no result @ all. please show me right way parse data?

i'm trying field following code:

   {    "data": [       {          "category": "tv show",          "name": "south park",          "id": "6708787004",          "created_time": "2013-05-19t14:53:15+0000"       },       {          "category": "tv show",          "name": "futurama",          "id": "9588466619",          "created_time": "2013-05-19t14:53:03+0000"       },       {          "category": "product/service",          "name": "rock zottegem",          "id": "79367311142",          "created_time": "2013-05-06t15:23:41+0000"       },       {          "category": "musician/band",          "name": "netsky",          "id": "85506412028",          "created_time": "2013-05-06t15:21:24+0000"       },       {          "category": "media/news/publishing",          "name": "tasty network",          "id": "186383034758939",          "created_time": "2013-05-06t15:21:10+0000"       },       {          "category": "musician/band",          "name": "ukf drum & bass",          "id": "274197690441",          "created_time": "2013-05-06t15:20:25+0000"       },       {          "category": "musician/band",          "name": "savant",          "id": "204538756277738",          "created_time": "2013-05-06t15:20:04+0000"       }    ],    "paging": {       "next": "https://graph.facebook.com/100005892006494/likes?access_token=awfibl9ud01fgmilwgpabzarzbucgjbzbp2xmt1fj3x5f3uhnvzbhpmqjhyxc6nzb8t0ecgokty9kczbezabbusnwrfqvnhvql0mouqqaldsr8genezi6iogasi64vnlhey9rlzak8y0wbgzdzd&limit=5000&offset=5000&__after_id=204538756277738"    } } 

and php code is:

$facebookrequest="https://graph.facebook.com/".$user."/likes?access_token=".$access_token."";    $likes = json_decode(file_get_contents($facebookrequest));    //$requests = file_get_contents($facebookrequest);              //print_r($likes);              foreach($likes $like => $item)         {             echo $item->name;         } 

you need access array data , grab name field each of it's children. doing trying grab name field array, doesn't exist.

try changing this:

foreach($likes $like => $item) 

to this:

foreach($likes->data $like => $item) 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -