So here I was trying to decode the post and comments in php but since I don’t know much on JSON, I stuck here and don’t know what else to code to decode the URL from the Graph API I’ve made.
$group_id ="1xxxxxxxxxxx3";
$access_token ="xxxxxxxxxxxxxx";
$url = "https://graph.facebook.com/v2.11/" . $group_id . "/feed
fields=comments{comments{message,from},message,from},message,from
&access_token=".$access_token;
$json= file_get_contents($url);
$obj = json_decode($json, true);
?>
I really need your help and maybe give me some explanation to the problem I’m suffering right now.
The result should be showing like this.
This is the result from the facebook page itself, I need these to come out in my own localhost pages
4
Answers
To display the whole JSON object:
Then you analyse its structure, and loop accordingly, using “foreach”.
If I understood correctly then all you want to do next is determine if it decoded OK and display it? You can try using the
json_last_error()
like thisI think you have not executed the URL. You need to first execute the URL in order to get the response from the Facebook graph API. Something like
If you can be more elaborate with your question. Have you decoded the Json ? If yes then you can simply use the JavaScript built-in function JSON.parse() to convert the string into a JavaScript object, and use the object in your page.