I'm having an issue with Facebook's PHP SDK version 4.0.
I'm simply trying to retrieve the insights/page_fans_city
metric via the Graph API:
$request = new FacebookRequest($session, 'GET',
'/{my object}/insights/page_fans_city',
array('period' => 'lifetime'));
$response = $request->execute();
$client_graph_object = $response->getGraphObject();
print_r($client_graph_object);
However, no data is returned:
Facebook\GraphObject Object
(
[backingData:protected] => Array
(
[data] => Array
(
)
[paging] => stdClass Object
(
[previous] => https://graph.facebook.com/v2.0/...
[next] => https://graph.facebook.com/v2.0/...
)
)
)
I know that I have the Insights data that I'm requesting. I can make the exact same request via the Graph Explorer:
→ /v.2.0/{my object}/insights/page_fans_city?period=lifetime
{
"data": [
{
"id": "{my object}/insights/page_fans_city/lifetime",
"name": "page_fans_city",
"period": "lifetime",
"values": [
{
"value": {
...
},
"end_time": "2014-08-01T07:00:00+0000"
},
{
"value": {
...
},
"end_time": "2014-08-02T07:00:00+0000"
}
],
"title": "Lifetime Likes by City",
"description": "Lifetime: Aggregated Facebook location data, sorted by city, about the people who like your Page. (Unique Users)"
}
],
"paging": {
"previous": "https://graph.facebook.com/v2.0/...,
"next": "https://graph.facebook.com/v2.0/...
}
}
I should note that I am receiving data if I omit the page_fans_city
segment. When it's omitted- I can view data for page_fans_country
only. Therefore
$request = new FacebookRequest($session, 'GET',
'/{myobject}/insights/page_fans_country',
array('period' => 'lifetime'));
and
$request = new FacebookRequest($session, 'GET',
'/{myobject}/insights',
array('period' => 'lifetime'));
will work for me ...
I suspect it's my Access token- but I'm not sure why that would be the case. The app that I created only requires the read_insights
permission.
Any thoughts or suggestions?
Thanks in advance,
Mike