简体   繁体   English

没有用户输入的Facebook Marketing API令牌

[英]Facebook Marketing API token without user input

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. 我目前正在创建一个服务器CLI应用程序,通过Marketing API检索facebook Ads指标,它会作为服务器上长期运行的服务来完成,而无需用户输入便会定期执行,但我似乎找不到找到获取方法的方法。这样做的令牌。

All procedures to get an access token from facebook PHP Api seem to assume a user is there to login to facebook. 从Facebook PHP Api获取访问令牌的所有过程似乎都假设用户在那里登录到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. 我迅速看了看是否可以手动连接curl,但是在Facebook登录过程中有一些js生成的变量,因此会使事情复杂化。

Is there any way to get Marketing API insight with only an app id/secret ? 有什么方法可以仅使用应用程序ID /秘密来获得Marketing API的见解? 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." 但是我收到一个错误“无法确定此请求的目标对象。当前支持的对象包括广告帐户,企业帐户和关联的对象。”

Do you have access to Business Manager ? 您可以访问业务管理器吗? You can generate a System User there which comes with a non-expiring token. 您可以在那里生成一个带有未过期令牌的系统用户。 See here . 看这里

With App ID and App Secret, you can only get an App Access Token. 使用App ID和App Secret,您只能获得一个App Access令牌。 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: 与该用户没有任何关系,因此Facebook无法知道是否允许您访问Marketing API或Insights:

To access the Marketing API you need a user access token having the permissions ads_management or ads_read 要访问Marketing API,您需要具有访问权限ads_management或ads_read的用户访问令牌

Source: https://developers.facebook.com/docs/marketing-api/quickstart#access-token 资料来源: 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. 您可以使用和存储有效期为60天的扩展用户令牌。

More information about Tokens and how to extend them: 有关令牌以及如何扩展它们的更多信息:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM