Check out this authentication page when you have access to the AdWords API: http://developers.facebook.com/docs/authentication/
In the end, you will need access_token, which depends on your application and the Facebook account you are accessing.
Here is our process:
- Log in to your Facebook account, which contains ad data.
- Paste this into this browser address bar:
https://www.facebook.com/dialog/oauth?client_id={your_application_id}&scope=ads_management,offline_access,read_insights&redirect_uri={your website} - You should go to a page that allows you to authorize your application for this Facebook account (green Allow )
- Copy the authorization code that appears after the = code in the redirected URL
- Paste this into this browser address bar (you may not have client_secret with your application if you do not try it without client_secret):
https://graph.facebook.com/oauth/access_token?client_id={your_application_id}&redirect_uri={your website}&client_secret={your application secret}&code={code you got from step 4} - You should go to the page containing access_token
I donβt think you need to save the authorization code, since access_token should not expire (if you requested offline_access), if the log information has not been changed for your Facebook account.
Downloading statistics To search for statistics, I would not use the outdated REST API, since Facebook will depreciate it. The Graph API allows you to automatically get statistics using:
GET https://graph.facebook.com/stats/{starttime}/{endtime}/stats?ids={campaign_id}&access_token=...
start time and end time can be in the format YYYY-MM-DD HH: MM: SS or as unix time (epoch?)
source share