Does anyone know a solution to this?
I’d like to display the sum of the different values with PHP. Something like:
Page post: (Sum of all)
Fan: (Sum of all)
User Post: (Sum of all)
….
Here is the JSON form the Facebook Graph APi.
{
"data": [
{
"id": "SOME_ID/insights/page_stories_by_story_type/days_28",
"name": "page_stories_by_story_type",
"period": "days_28",
"values": [
{
"value": {
"page post": 357,
"fan": 229,
"user post": 84,
"question": 72,
"mention": 4
},
"end_time": "2012-01-22T08:00:00+0000"
},
{
"value": {
"page post": 356,
"fan": 229,
"user post": 85,
"question": 73,
"mention": 4
},
"end_time": "2012-01-23T08:00:00+0000"
},
{
"value": {
"page post": 401,
"fan": 231,
"user post": 88,
"question": 73,
"mention": 4
},
"end_time": "2012-01-24T08:00:00+0000"
},
],
"title": "28 Days Page Stories by story type",
"description": "28 Days The number of stories about your Page by story type. (Total Count)"
}
],
"paging": {
"previous": "https://SOME_LINK",
"next": "https://SOME_LINK"
}
}
I am not sure why, but the json you provided is not being decoded using standard
json_decode, so I had to use a custom function found onhttp://php.net/manual/en/function.json-decode.phpThis is the code:
The result is something like this: