I am trying to display the latest group posts from a public group on my website and I'm using the following code to display the raw data, which works fine.
try {
$response = $fb->get('25366400942/feed?fields=message,updated_time,from');
$graphEdge = $response->getGraphEdge();
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
foreach ($graphEdge as $content){
echo $content . "<br><br>";
}
With the above code i get something like the following:
{"message":"This is a Facebook group message.","updated_time":"2016-01-10T11:27:09+0000","from":{"name":"John Doe","id":"10208143097521312"},"id":"25366400942_10153729825005943"}
My problem is when trying to format the output. I can easily display the message and id by using $content['message'] and $content['id'] but when I try to display the date using $content['updated_time'] the code just stops, like the field doesn't exist. I've also tried to cast to a date using strtotime and new DataTime but that just creates an empty date.
So what am i doing wrong? There clearly is a field called updated_time and it clearly has a value, so why can't I extract the data?