Facebook Marketing API token without user input

Digital Marketing Facebook Marketing API 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating
_x000D_ _x000D_ I'm currently creating a server CLI application retrieving facebook Ads metrics through the Marketing API, it would be done as a long running service on the server doing so periodically without user input, but I can't seem to find a way to get a token for doing so. All procedures to get an access token from facebook PHP Api seem to assume a user is there to login to facebook. I looked quickly to see if I could connect manually with curl but there is some js generated variables in the facebook login process, so that would complicate things. Is there any way to get Marketing API insight with only an app id/secret ? Or is it possible to retrieve an access token without user input ? The closest I've been is this : Api::init( 'appID', // App ID 'APPSECRET', "appid|appstring"// APP token ); $campaign = new Campaign('campaignID'); $params = array( 'date_preset' => InsightsPresets::LAST_7_DAYS, ); $insights = $campaign->getInsights([], $params); print_r($insights); But I get an error "Cannot determine the target object for this request. Currently supported objects include ad account, business account and associated objects."

Posted on 16 Aug 2022, this text provides information on Facebook Marketing API related to Digital Marketing. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago
_x000D_ With App ID and App Secret, you can only get an App Access Token. There is no relation to any User with that one, so there is no way for Facebook to know if you are allowed to have access to the Marketing API or Insights: To access the Marketing API you need a user access token having the permissions ads_management or ads_read Source: https://developers.facebook.com/docs/marketing-api/quickstart#access-token You can use and store an Extended User Token that is valid for 60 days. More information about Tokens and how to extend them: https://developers.facebook.com/docs/facebook-login/access-tokens http://www.devils-heaven.com/facebook-access-tokens/

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.