Issue
Is there a way to request Facebook ads api without getting an access token though a web interface (with oauth delegation)?
Looking at the documentation it's all about redirect and oauth classic login steps.
But a server may need to gather data without human contribution; it's not doable to display a Facebook login screen every two weeks to get a new valid access token.
Can this access token be generated through an api call?
// this call generates an app token, but end up with an exception
// "You do not have sufficient permissions to perform this action"
// on every api call relative to campaign, creative & co
https://graph.facebook.com/oauth/access_token?client_id={id}&client_secret={secret}
I'm missing something?
// Using the php ads sdk
use FacebookAds\Api;
Api::init($app_id, $app_secret, $access_token);
// where app_id and app_secret can be found in the ad account preferences
// and access_token has to be generated — but how?
Solution
This steps are working.
- Get a short-lived token (with the
manage_pages
permission) though the Graph API Explorer - Convert this short-lived access token into a long-lived one though https://graph.facebook.com/oauth/access_token?client_id=&client_secret=&grant_type=fb_exchange_token&fb_exchange_token=
- Convert this long-lived access token in a permanent one (Expires: Never) though https://graph.facebook.com/me/accounts?access_token=
Answered By - yves amsellem
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.