Sunday, February 27, 2022

[FIXED] Facebook ads api flow server side

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.



Answered By - yves amsellem

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.