Facebook page insights lifetime metrics doesn't return results - facebook

I'm trying to get some insights on page I own, for example page_fans which is stated in https://developers.facebook.com/docs/graph-api/reference/v3.2/insights as having both "day" and "lifetime" periods. (This is NOT the only metric I want to get but for the sake of simplicity I'll give it as an example.)
Getting it by day works, but I only wa
nt to know the lifetime value, so instead of period=day I tried period=lifetime, and I get an empty data array.
This is the request I am sending:
{page_id}/insights?fields=&metric=page_fans&period=lifetime
Note, if I change to period=day I get a nice object:
"data": [
{
"name": "page_fans",
"period": "day",
"values": [
{
"value": 21578,
"end_time": "2019-02-24T08:00:00+0000"
},
{
"value": 21580,
"end_time": "2019-02-25T08:00:00+0000"
}
],
"title": "Lifetime Total Likes",
"description": "Lifetime: The total number of people who have liked your Page. (Unique Users)",
"id": "{page_id}/insights/page_fans/day"
}
],
Other metrics I want to get lifetime data for include:
"post_video_view_time_by_region_id",
"post_video_views_by_distribution_type",
"post_video_view_time_by_distribution_type",
"post_video_view_time_by_country_id"

According to the changelog for v3.2
Page Insights
These changes apply to v3.2+, and will apply to all versions on January 21, 2019.
Period parameters have been changed to day from lifetime for
the following metrics. The lifetime period parameter will return
an empty dataset.
page_fans
page_fans_city
page_fans_country
page_fans_gender_age
page_fans_locale

You can use /insights?metric=page_fans&date_preset=maximum

Related

Facebook Marketing API Campaign spend_cap field returns inconsistently

I'm trying to pull data for each of my Ad Campaigns from the Facebook Marketing API.
In the Ads Insights API there is only a 'spend' field that returns how much of the budget for that campaign has been spent so within the specified date range parameter. This is documented at
developers.facebook.com/docs/marketing-api/insights/fields/v2.9
I would like to get the 'spend_cap' field that's specified in the Reference section of the Marketing API located in the link below. One thing I noted was that there are no parameters available to this node, that may be why the spend_cap is not returning. This is documented at
developers.facebook.com/docs/marketing-api/reference/ad-campaign-group
I am using the following url to request the data.
https://graph.facebook.com/v2.9/{act_id}/campaigns?fields=name,spend_cap&access_token={access_token}
However, it returns the spend_cap field inconsistently, as shown below. I've only included a couple examples but I'm certain that all my campaigns are set up with spending caps.
data:[
{
"id": "##############",
"name": "name1",
"start_time": "2016-06-24T14:47:34-0400",
"stop_time": "2016-07-03T14:47:34-0400"
},
{
"id": "##############",
"name": "name2",
"spend_cap": "30000",
"start_time": "2016-05-16T11:57:10-0400"
},
{
"id": "##############",
"name": "name3",
"spend_cap": "15000",
"start_time": "2016-05-16T11:44:06-0400",
"stop_time": "2017-04-01T00:00:00-0400"
},
{
"id": "##############",
"name": "name4",
"start_time": "2016-05-13T15:34:41-0400",
"stop_time": "2017-05-13T09:46:44-0400"
}
]
The spend_cap at the campaign level is an optional field which is why it is only returned for some of the campaigns.
In general within the Graph API, if a field contains no data, this field will be omitted from the response.
Our SDKs abstract this for you so you can always access a field of an object, regardless of whether it was in the response, so if you're not using one of our SDKs, you'll have to do the same.

Has Facebook deprecated the /EVENT_ID/invited part of their API?

I'm trying to figure out how to access the guest list data of an event on Facebook and the example given in the Facebook documentation located at https://developers.facebook.com/docs/reference/api/event/ is:
https://graph.facebook.com/331218348435/invited
However, when I test this in the explorer I get:
{
"error": "Request failed"
}
Am I missing something?
The endpoint is most definitely not deprecated.
The problem here is that there are simply too many people invited to that event! There are too many results to return in a single query...
If you specify a limit you will get the results you need:
https://graph.facebook.com/331218348435/invited?limit=10
The response for that request would be something like this :
{
"data": [
{
"name": "xxx",
"rsvp_status": "attending",
"id": "111"
},
{
"name": "yyy",
"rsvp_status": "attending",
"id": "222"
},
... (8 more results) ...
],
"paging": {
"next": "https://graph.facebook.com/331218348435/invited?limit=10&offset=10&__after_id=29606639"
}
}
Note that there is a paging result returned as well - this is the URL you will need to query in order to get the next batch of results. It uses the limit parameter and also the offset parameter to ensure that you don't get duplicate results.
In my example, I've given a limit of 10 users per response, but I've managed to get data even when specifying 1000 results. The bigger the limit you provide the longer the request will take to return data.

How far can I go back with Facebook Insight API?

I have been trying to get historical data for Facebook pages. I was wondering how to determine how far back I can go.
So I know I can go one month back. Is this a rolling window? I also would like to know how far I can go back and not get an api exception like follows.
{
"error": {
"message": "Unsupported operation",
"type": "FacebookApiException",
"code": 100
}
}
Is it possible to get all the historical insight data for a given fan page that I have access to.
Thanks and any suggestions that might help with understanding how to do this cleanly and robustly are also welcome.
Start with 30 days ending on the current day, e.g.
/278905338821044/insights/page_fans/lifetime?since=30 days ago&until=now
The response will have the last 30 days' data, and you can iteratively go through the 'previous' links in the paging structure at the end to go back into the past
{
"data": [
{
"id": "278905338821044/insights/page_fans/lifetime",
"name": "page_fans",
"period": "lifetime",
"values": [
{
"value": 1432,
"end_time": "2012-09-19T07:00:00+0000"
},
//snip
{
"value": 1438,
"end_time": "2012-10-16T07:00:00+0000"
}
],
"title": "Lifetime Total Likes",
"description": "Lifetime The total number of people who have liked your Page. (Unique Users)"
}
],
"paging": {
"previous": "https://graph.facebook.com/278905338821044/insights/page_fans/lifetime?since=1345405748&until=1347997748",
"next": "https://graph.facebook.com/278905338821044/insights/page_fans/lifetime?since=1350589748&until=1353181748"
}
}

Facebook Graph API returns Shares instead of total count

I am having an issue when trying to return the total_count number for our Like buttons. Our application manages Like buttons and Open Graph tags, we have a few URLs we are trying to get the Like count for, but it is returning shares with no OG tag information.
For example:
https://graph.facebook.com/?id=http://www.fruitilike.com/products/shares-debug6/
Returns:
{
"id": "http://www.fruitilike.com/products/shares-debug6/",
"shares": 1
}
Example of how it should work:
https://graph.facebook.com/?id=http://www.fruitilike.com/products/apple
Returns:
{
"id": "114182628680532",
"name": "Apple",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/187789_114182628680532_2291233_s.jpg",
"link": "http://www.fruitilike.com/products/apple",
"likes": 1,
"app_id": 102729306450470,
"category": "Food",
"is_published": true,
"description": "The Apple. When it falls from a tree it generates gravity.",
"about": "The Apple. When it falls from a tree it generates gravity."
}
There is nothing wrong with those results, this is due to fact that objects you compare have different types:
http://www.fruitilike.com/products/shares-debug6/ - is website
http://www.fruitilike.com/products/apple/ - is food
It totally ok to have different sets fields for different types of objects.

Insights before 2010-04-02 are missing?

I'd like to get Insights data before 2010-04-02, but it seems to be impossible to retrieve via the Graph API or FQL query. If you make a Graph API request spanning over 2010-04-02 you will get results starting at 2010-04-02 and going forward with the rest simply missing. Can any one explain this or have a way to get around this limitation?
Here is an example of the problem: http://developers.facebook.com/tools/explorer/?method=GET&path=2439131959%2Finsights%2Fapplication_active_users%3Fsince%3D2010-03-28%26until%3D2010-04-10%26date_format%3DY-m-d
There should be results from 2010-03-28 to 2010-04-10, but you only get 2010-04-02 and onwards.
{
"data": [
{
"id": "2439131959/insights/application_active_users/day",
"name": "application_active_users",
"period": "day",
"values": [
{
"value": 172118,
"end_time": "2010-04-02"
},
{
"value": 177263,
"end_time": "2010-04-03"
},
{
"value": 176568,
"end_time": "2010-04-04"
},
{
"value": 190725,
"end_time": "2010-04-05"
},
...
Maybe your insights were a "victim" of this: https://developers.facebook.com/docs/reference/fql/insights/
We are deprecating some old insights. These metrics are marked as
deprecated throughout this document. After 12/21/2011, data for these
metrics won't be available prior to 07/19/2011 -- please download this
data before this 12/21/2011. These insights will be completely removed
from API after 02/15/2012.