How can I programmatically retrieve Facebook Audience Network performance data by hour? - facebook

I'm spinning my wheels over here and could use some help.
For our internal app analytics system, I have a script that currently uses the FB App Insights Reporting API to get basic Fb Audience Network ad metric data (requests, impressions, revenue, etc.):
https://developers.facebook.com/docs/graph-api/reference/v2.6/application/app_insights
It only reports data by day though (even though it misleadingly returns a Timestamp with the response), and we now have a business need to collect this data by hour, so we can accurately generate reports for any time zone.
I came across another part of the Graph API that seems built for this specific reporting purpose, and, according to the documentation, does support hourly granularity:
https://developers.facebook.com/docs/graph-api/reference/v2.6/user/adnetworkanalytics
I am moderately familiar/comfortable with FB API security and design, but for the life of me I cannot get anything but an empty data list back from this API edge. Sample request:
https://graph.facebook.com/v2.6/<user_id>/adnetworkanalytics?since=1467176400&until=1467262800&event_name=fb_ad_network_request&aggregateBy=COUNT&breakdowns[0]=country&breakdowns[1]=placement&breakdowns[2]=app&period=hourly&access_token=<user_token>
From what I can tell this means that the 'User' (me, or technically the dummy app I have set up to access Insight API data through) does not have correct permissions to access this data, and indeed when I check my permissions I do not see the associated permission, read_audience_network_insights listed.
I have tried to add the permission to the app I am accessing this through by adding the permission through the Graph API Explorer in the dialog that pops up when you select 'Get User Access Token.' However, even after adding there I still do not have the associated permission granted, even though it shows in the dialog if I go through the process again:
I think this is because I have to submit this App to FB Review for that specific permission, but when I try that, I do not see the permission available to be selected for review.
SUMMARY:
Like my title says, my goal is just to get my FB Audience Network data by hour. I'm open to any programmatic way of doing this (preferably something I can implement in a python script). If that means someone helping me get permission and successfully use the adnetworkanalytics edge that is great. If it is through other means I am not aware of yet, that is great too. Thank you!

Related

(#200) Access to this data is temporarily disabled for non-active accounts due to changes we are making to the Facebook Platform [duplicate]

We have some code that uses Facebook Open Graph API to display some posts on our home page. It was originally developed by a previous developer and I rewrote it in ASP.NET MVC for our home page (where before it was PHP which I believe was loaded in an iframe). At that time, I used the app ID and secret that were left to me. This has functioned fine for a couple of years. This afternoon, we started getting an error back on our site: "Access to this data is temporarily disabled for non-active accounts due to changes we are making to the Facebook Platform".
No sweat. I figured I just needed to update our ID and secret. Unfortunately, no one seems to remember the user ID that was in control of that app ID. No sweat. I'll make my own. Unfortunately, any ID and secret I use to access posts -- even my own posts on a page totally not related to work -- returns the same access error. I can get name or cover or some other fields, but as soon as I request any posts, I get the error.
Here's an example of what I'm trying:
https://graph.facebook.com/MyCompanyName?fields=cover,name,likes,link,posts.limit(5){created_time,message,link,type,full_picture,picture,source,icon}&access_token=bunchofnumbers|bunchofnumbersandletters
I am aware of the status post at https://developers.facebook.com/status/issues/205942813488872/, but I think I must be doing something wrong since I can't even create new appIDs to get posts with.
Why does Facebook Graph API say my account is non-active?
Thanks.
Please read this article:
Mark Zuckerberg apologises for Facebook's 'mistakes' over Cambridge Analytica
Cambridge University researcher named Aleksandr Kogan had used an app to extract the information of more than 50 million people, and then transferred it to Cambridge Analytica for commercial and political use.
So facebook is changing its policies so that the personal data could be made more secure.
Until then you cant do anything about it.
I solved the problem on my website by removing the events from the fetched fields list
We started seeing this same error message on our platform today. I think there are a few things going on that all tie together:
As others have mentioned, there have been rapid and major responses by Facebook to increase data protection and privacy in light of the Cambridge Analytica incident. From what I understand, the bad actors exploited the ability access the data of Users (via the graph) that the app did not have an active, first-party relationship with. So, sort of like how "6 degrees of separation" would get you the whole planet, the 1 degree of separation on the few-hundred-thousand Users that connected with the app directly gave the app access to roughly 50 Million users...or something like that. FB is doing what they can to lock that stuff down now, big time.
The specific cause of your error is that something you're asking for in the fields parameter makes a leap (from the either the myCompany or the OAuth'd User/App whose access_token you are using) to a related item/items that FB now deems must have an "active" first-party/direct relationship with your Company/App/User in order to access. This is why you see the somewhat cryptic "non-active accounts" mentioning. I think they really mean that it's not "active with you or your app".
I'm not sure which one of the fields you request is at fault, but some trial-and-error will lead you to it. For us, it was clear: we were asking for the Members of all the Groups that User had access to. We didn't need that, so we cut it out and the error went away.
Facebook today updated the term and conditions
https://developers.facebook.com/docs/graph-api/changelog/breaking-changes/?translation&hc_location=ufi#groups-4-4
My understanding is that if your not a production app, they are limiting your for specific reasons. Unclear if thats because of Cambridge Leak, or upgrading the instagram api.
I also received the same error, however, if you are testing, you can hard code the graph api explorer token into your app to continue testing...
var data {
'accessToken': 'EEAC...',
}
FB.api('/' + id, getData, data, (_response) => {
console.log(_response);
});
Right now I am working with Facebook Open Graph API. And I was having this error every time I wanted to access/get the member (and their basic info) of the groups I am Admin.
{
"error": {
"message": "(#200) Access to this data is temporarily disabled for non-active accounts due to changes we are making to the Facebook Platform",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "Byueyj6MtkoIx"
}
}
In between trial and error #JoshChristy was getting all the desired results! And after couple hours of research we discovered that facebook recognize some account as "non-active" and some "active" (I don't know based on what!) because I am pretty much active in facebook.
So, if you are getting this error that means you are not active enough for facebook ;)
I had this problem. It's solved automatically. I think it's a Facebook issue.
For me it work if I leave just one field - "name". If I add "link" and/or "events" fields it returns error
I was able to get Facebook Page Access token using the method below.
For anyone who may already have an app which has been reviewed can use that app's details as a temporary fix until Facebook is done with their API enhancements. Meaning you'll have to add the relevant redirect uris to the reviewed app as well as use that app's App Id and App Secret.
This works for retrieving page feeds and leads, I wasn't able to retrieve conversations. Also the permissions I requested were { scope: 'ads_management,ads_read,manage_pages' }
In our case, we retrieved, for example, a page access_token with a page ID using like this:
this.call('v2.12/'+pageid, 'GET', {fields: "access_token"}, token)
ended up with the error you mentioned.
However, we took a normal approach and all looks good now.
https://developers.facebook.com/docs/facebook-login/access-tokens#pagetokens
Same thing I just noticed too, and they kept my lead gen ads running and charging me eventhough they blocked the data.
Luckily going into ad manager directly you can still download the CSV/XLS files.
What is issue?
This error is due to recent action taken by Facebook. They said ” Access to certain types of API data is paused for non-active accounts due to changes we are making to the Facebook Platform” So if your account is non-active and you have created App using it then it might possible you get this error in your Plugin. Facebook Issue link is
When it will resolved?
Facebook has temporarily disabled some non-active accounts as they mentioned they haven’t given any estimated time to fix issue but it should get activated soon.
You can find more update on facebook Event API here

Why does Facebook Graph API say my account is non-active?

We have some code that uses Facebook Open Graph API to display some posts on our home page. It was originally developed by a previous developer and I rewrote it in ASP.NET MVC for our home page (where before it was PHP which I believe was loaded in an iframe). At that time, I used the app ID and secret that were left to me. This has functioned fine for a couple of years. This afternoon, we started getting an error back on our site: "Access to this data is temporarily disabled for non-active accounts due to changes we are making to the Facebook Platform".
No sweat. I figured I just needed to update our ID and secret. Unfortunately, no one seems to remember the user ID that was in control of that app ID. No sweat. I'll make my own. Unfortunately, any ID and secret I use to access posts -- even my own posts on a page totally not related to work -- returns the same access error. I can get name or cover or some other fields, but as soon as I request any posts, I get the error.
Here's an example of what I'm trying:
https://graph.facebook.com/MyCompanyName?fields=cover,name,likes,link,posts.limit(5){created_time,message,link,type,full_picture,picture,source,icon}&access_token=bunchofnumbers|bunchofnumbersandletters
I am aware of the status post at https://developers.facebook.com/status/issues/205942813488872/, but I think I must be doing something wrong since I can't even create new appIDs to get posts with.
Why does Facebook Graph API say my account is non-active?
Thanks.
Please read this article:
Mark Zuckerberg apologises for Facebook's 'mistakes' over Cambridge Analytica
Cambridge University researcher named Aleksandr Kogan had used an app to extract the information of more than 50 million people, and then transferred it to Cambridge Analytica for commercial and political use.
So facebook is changing its policies so that the personal data could be made more secure.
Until then you cant do anything about it.
I solved the problem on my website by removing the events from the fetched fields list
We started seeing this same error message on our platform today. I think there are a few things going on that all tie together:
As others have mentioned, there have been rapid and major responses by Facebook to increase data protection and privacy in light of the Cambridge Analytica incident. From what I understand, the bad actors exploited the ability access the data of Users (via the graph) that the app did not have an active, first-party relationship with. So, sort of like how "6 degrees of separation" would get you the whole planet, the 1 degree of separation on the few-hundred-thousand Users that connected with the app directly gave the app access to roughly 50 Million users...or something like that. FB is doing what they can to lock that stuff down now, big time.
The specific cause of your error is that something you're asking for in the fields parameter makes a leap (from the either the myCompany or the OAuth'd User/App whose access_token you are using) to a related item/items that FB now deems must have an "active" first-party/direct relationship with your Company/App/User in order to access. This is why you see the somewhat cryptic "non-active accounts" mentioning. I think they really mean that it's not "active with you or your app".
I'm not sure which one of the fields you request is at fault, but some trial-and-error will lead you to it. For us, it was clear: we were asking for the Members of all the Groups that User had access to. We didn't need that, so we cut it out and the error went away.
Facebook today updated the term and conditions
https://developers.facebook.com/docs/graph-api/changelog/breaking-changes/?translation&hc_location=ufi#groups-4-4
My understanding is that if your not a production app, they are limiting your for specific reasons. Unclear if thats because of Cambridge Leak, or upgrading the instagram api.
I also received the same error, however, if you are testing, you can hard code the graph api explorer token into your app to continue testing...
var data {
'accessToken': 'EEAC...',
}
FB.api('/' + id, getData, data, (_response) => {
console.log(_response);
});
Right now I am working with Facebook Open Graph API. And I was having this error every time I wanted to access/get the member (and their basic info) of the groups I am Admin.
{
"error": {
"message": "(#200) Access to this data is temporarily disabled for non-active accounts due to changes we are making to the Facebook Platform",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "Byueyj6MtkoIx"
}
}
In between trial and error #JoshChristy was getting all the desired results! And after couple hours of research we discovered that facebook recognize some account as "non-active" and some "active" (I don't know based on what!) because I am pretty much active in facebook.
So, if you are getting this error that means you are not active enough for facebook ;)
I had this problem. It's solved automatically. I think it's a Facebook issue.
For me it work if I leave just one field - "name". If I add "link" and/or "events" fields it returns error
I was able to get Facebook Page Access token using the method below.
For anyone who may already have an app which has been reviewed can use that app's details as a temporary fix until Facebook is done with their API enhancements. Meaning you'll have to add the relevant redirect uris to the reviewed app as well as use that app's App Id and App Secret.
This works for retrieving page feeds and leads, I wasn't able to retrieve conversations. Also the permissions I requested were { scope: 'ads_management,ads_read,manage_pages' }
In our case, we retrieved, for example, a page access_token with a page ID using like this:
this.call('v2.12/'+pageid, 'GET', {fields: "access_token"}, token)
ended up with the error you mentioned.
However, we took a normal approach and all looks good now.
https://developers.facebook.com/docs/facebook-login/access-tokens#pagetokens
Same thing I just noticed too, and they kept my lead gen ads running and charging me eventhough they blocked the data.
Luckily going into ad manager directly you can still download the CSV/XLS files.
What is issue?
This error is due to recent action taken by Facebook. They said ” Access to certain types of API data is paused for non-active accounts due to changes we are making to the Facebook Platform” So if your account is non-active and you have created App using it then it might possible you get this error in your Plugin. Facebook Issue link is
When it will resolved?
Facebook has temporarily disabled some non-active accounts as they mentioned they haven’t given any estimated time to fix issue but it should get activated soon.
You can find more update on facebook Event API here

How does Facebook API Rate Limit work for App Access Token?

I'm working on a project where an app displays events in the near surrounding based on the personal preferences of the user. We plan on getting the events from the Facebook Graph API using this approach. Due to Facebook's API changes it is much more complicated to search for events in a particular city. Therefore it requires much more API calls than before and i'm worried about FB rate limit.
We want to get the information about events by calling the Graph API with our app access token from our server and then store the data temporarily in our own database. So every time a user searches for events in our app, the client gets the information from our database. Moreover the user can (but don't has to) log-in with his Facebook account in order to provide us more information about him. We want to use the user's access token to call the API in order to get the user's likes.
I've read the FB documentation about the rate limits and some posts here on the site. Apparently FB calculates the number of calls based on the active users (200 calls per user every hour). It says that
"These limits apply to calls made using any access token other than a
page access token"
ergo they also apply to the app access token. Additionally in the FB policy it says something about 100M calls per day.
So my questions are:
How does the rate limit work on a per user basis if I am using my App Access Token?
To what token does the "100M" number belong? Is it an overall number for all tokens used by the app?
A similiar question has been posted here some time ago but didn't receive any answers. I hope maybe someone got new information since then. An answer to these questions is crucial to our project, so bear with me if you've read that question before.
Thanks in advance!
Please check this
Facebook Rate Limits

Facebook graph API returns empty data for a page

I have an application that is retrieving data from Facebook. Users authorize the application to read and write to their pages, and we read their data and post to it from our application. All interaction occurs via the PHP interface that Facebook supplies.
For the last few months our application has been performing this task flawlessly. However in recent days we have started noticing an issue with certain pages.
We go out and retrieve data for a specific page, and we no longer get any data. Instead Facebook returns us an empty result. This obviously causes problems in our application which needs to read this data.
We can still write data just fine.
I am at a point where I'm not sure what this could be. Any common scenarios or recent Graph API issues that could cause this?
This sounds odd. The only thing that comes to mind is that the page owner has put a restriction on the audience for their page, which would then require you to pass in an access token to access data about the page. An example would be a beer company that wants to limit access to their FB page to users that are older than 21. Since there is a restriction on who can access the page content, we enforce that restriction on the FB platform. In this case you would need to pass in the access_token of a user who is 21 or older to access the page details via the graph api.
Adding to Jeff's answer, I found that any kind of restriction whatsoever will return a blank data object. I was banging my head on every single setting on my company's page and found that we had it set to only show in certain countries (Manage Settings > Country Restrictions). Removing all of them from the list started to return all the data we needed.

How to simulate silent login to Facebook Graph API?

I'm working on an API that will aggregate data from several website, including facebook. The API has an engine that harvests data on regular intervals, and then the client app polls the API to get the data from all websites centrally.
The problem is that the API has no way of authenticating on the regular, behind-the-scenes harvests, as Facebook insists that the user has to click on the OAuth Dialog. With the short story being that there is no way to login to graph API silently this almost means that developing such an API is not possible (except for harvesting only public data).
However, I'm not easily satisfied by "it's not possible" answers and my clients - even less so. Accessing private information on demmand is defnitely possible as Facebook apps do that. For example, the official Twitter app posts on my wall whenever I tweet. I guess apps only need a permission once and then can access the user's profile as much as they like.
So this leads me to think that I should do a combination of a Graph API client and an application that talk to each other, and whenever the API needs to harvest - it asks the app to get the data and fetch it to the API. Or maybe it should be a push model (the app sends the data whenever it's generated) rather than pull (the API requests the data at regular intervals).
Am I on the right track? Is any of these the correct design approach?
I did some searching but it's very hard to find any useful discussion on the topic as whatever keywords I try I only find "Can I login silently? No" type of discussions.
You'll want to look into the offline_access permission. This lets you access a user's data when they don't have an active session, or are offline. That's as close to "silent login" as you can get.