Choosing correct authentication aproach when working with Facebook Ads API - facebook

I am very new to Facebook Ads API so some help or advices about best practices I can use in my case would be appreciated a lot.
The situation:
We have multiple clients that are running advertising campaigns on social sites and Search Engines like Facebook, LinkedId, Google Adwords, Bing and etc. They want to have information from all their campaigns in one database and use this database to run various reports in order to manage their campaigns better (move money from one campaign to another and have better results). So basically we need to perform daily (or should I say nightly) sync. Also we need to mark adds in Facebook that are part of campaigns that are running via our tool (also not a problem to do once logged in). This is done automatically.
That is not a problem in many platforms - we use Google and Microsoft API to connect to the platform, read required data on daily basis or do some changes to URLs automatically.
The question
I was a bit surprised to find out that in Facebook Ads API the only way to authenticate is via tokens that expire quite fast (long term tokens last for 60 days). I am wondering if it is possible to authenticate via API with user name and password or obtain the ticket that is not expiring. The reason - most of our processes will run on nightly basis so any interaction with user to get fresh ticket is not possible.
Asking for permission every 60 days also seems like not an option and offline_access privileges that would suit us perfectly are no longer supported as I understood correctly from the documentation.
So what are authentication options? Is the only possibility to ask user to re-confirm our access rights every 60 days? Is it possible to get access permission once and live with it until user revokes it, or this is not possible?
Thanks in advance for your answers and suggestions!

Facebook did an exception for ads api access tokens. It is still possible to get neverending access token. Reed more here https://developers.facebook.com/roadmap/offline-access-removal. Also, you can check access token type, expiration date and other params here https://developers.facebook.com/tools/debug. Our access tokens shown as Expires: Never.

Related

Graph API empty events list of page [duplicate]

Using the latest version (2.12) of the Facebook API I'm trying to get (public) events for a page, using the Graph API Explorer.
However, I can't seem to get it working:
When I hover over the greyed out "id" or "name" on the left, it says "Field is empty or disallowed by the access token".
Now the page I'm using as an exmple here is Techcrunch, and they have plenty of events coming up. So "empty" doesn't seem to be the issue.
On the "disallowed" side I've checked the API reference on https://developers.facebook.com/docs/graph-api/reference/page/events/.
However, I can't seem to find any issue here either. It says "Reading Page events requires a valid Page access token or User access token with basic permissions.".
What am I missing here? Any hints are greatly appreciated!
Visit https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#pages-4-4
Currently Facebook is not returning events for pages using Pages API unless you use an user accesss token and that user has been invited to any of the events of the page or is attending/interested in any of the events of the page.
As unknow_b said :
currently to access events you can also use a user endpoint such as ‘/me/events’ or ‘/me/events/not-replied’ using an access token valid for that user. you can get the events that the user was invited to or is going/interested
But the access token user, is only working for 1 hour !
Does someone have another better idea?
I'm trying to do the same thing: getting public events from a page. Related to the above suggestions:
I tried the short-lived user access token two weeks ago, which worked for a short time. Now it does not anymore. Does it for any of you?
Both the long-lived user token, a page token generated with either a short- or long-lived user token do also not return any events.
At https://developers.facebook.com/docs/apps/review/#platforms, Facebook states:
Beginning April 4, 2018, all apps, including those formerly approved, must undergo App Review in order to gain access to the Events API, Groups API, and Pages API. Apps accessing the Events API and Groups API will lose access and require review once App Review resumes.
So being reviewed might help. I will report further.
Update 1: an answer on this related bug reports states it more clearly:
App review required to use the following edges: GET /page/events and GET /me/events
Meanwhile they cancelled all pending review requests for the Graph API 3.0 changes, so I have to resubmit.
Update 2: My project got rejected & I'm not bothering to continue it now.
Yep. Facebook has taken down the Graph API for page access tokens. I had this code in production for 2 years and it worked great. The only way to retrieve data (or was a week or so ago), was a temporary user token that lasts about 2 hours. It's totally broken my band's schedule page. I've been through every avenue and even spoke with a facebook ad team employee on the phone that was aware of it. She seemed to empathize but had no solution for me. I would count on it being down for a while.
I just created a python script, you can see here. It queries the given facebook page and it's events, and puts the data into a mysql table.
It looks like it won't be working anymore due to the scandal with Facebook Analytics (see Why does Facebook Graph API say my account is non-active?).
In the popular plugin facebook-events-by-location-core, you can take a look into the issue#29 discussion. It's well explained there, and I don't think so there's a way we'll get the data in a public API available anymore.
There were also some rumours it was a competition for their (dead?) Facebook Local app, but not sure about this.
I have finally figured out a work around for this. On your fb application, you have to disable the secret key requirement. This can be found under the advance settings of your fb application console. It's called " Require App Secret".
Once you generate a fb PAGE access token, you get a fb page token, and then extend it. here is the token debugger: https://developers.facebook.com/tools/explorer/
You can extend the access token programmatically as explained here: https://developers.facebook.com/docs/facebook-login/access-tokens/expiration-and-extension
AND
https://developers.facebook.com/docs/facebook-login/access-tokens/#pagetokens
OR
There is also an extend tool in the access token debugger (just click on the debug and the extend button is bottom left): https://developers.facebook.com/tools/accesstoken/
Yes , we had a working product back in 2016 ( almost like it's successor Fb Local ) . We were monetised and ready and selling events tickets on the messenger chatbot.
Idea was to solve discovery + booking for hyperlocal events. We went out of business and now its a heart ache to see Fb local.
enter image description 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

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

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!

Permanently associating a website's account to facebook account

I have the task to integrate some commercial sharing stuff into a website.
The idea is that the user a) logs in/registers in the website, b) the user connects his user account with his facebook account - by adding and accepting the website application.
Here comes the interesting part - is there a way of linking the facebook account with my website's account so that I can send them updates and promotions directly to their walls programatically?
In the application dialog, it's clearly noted that the user allows the application to write to the user wall so they accept and agree this. Then, for example, if I want to send them a promotion or update directly on their wall using the fb application api, how can I achieve this? All the tutorials I've read consider the user using the Facebook Login
The concrete idea is something like weekly promotion feed that my clients want to allow customers to allow being posted directly on their walls. As I don't have any experience with facebook development, I'd appreciate knowing how, if at all possible, this can be achieved?
Most of what you're suggesting is against policy, and isnt' technically possible either as users need to come back to the app once every 60 days for you to have a valid access_token for them.
The Authentication docs explain how to get access to a user's information with their permission, and the Permission documentation explains which permissions grant access to which functions or fields.

Can I create an application which monitors a user's activity on Facebook?

I wish to create an application which me and my friends would subscribe to and which in turn can monitor a count of items in the news feed using the required permissions (kind of a social network statistics).
I read the developer documentation, but I couldn't find out if it's possible. Subscribing to my application (and allowing the permissions) is a one-time process for my friends. From then on, can my application read the fields mentioned in Graph API for the subscribed users at any time (without the user's involvement)?
You might be interested in using the Real-Time Updates API from Facebook. Using this, you will no longer have to continuously "poll" the Graph API. Rather, Facebook will send the updates to your server.
Here are some sample implementations of the API, https://github.com/facebook/real-time/tree/master/samples.
No.
Facebook used to have the "offline_access" permission which would let applications have an access token that does not expire.
Not a while ago though Facebook deprecated this permission as stated in Removal of offline_access permission.
The longest (that I'm aware of) that a token is valid for is 60 days. If you want to extend that time frame you'll have to get the user to interact with your application.