jsonfacebookfacebook-graph-api

Facebook graph json output


Here is what I get:

{
"data": [
{
"name": "company name",
"id": "123456789123456"
}
],
"paging": {
"cursors": {
 "before": "MAZDZD",
"after": "MAZDZD"
}
}
}

How do I get the id? I have tried $content->data[0]->id but no luck ($content is the json array)


Solution

  • If print_r($content) is outputting exactly that, you haven't decoded the JSON into something PHP can understand.

    $content = json_decode($content);