首页 文章

在Facebook上使用相同的令牌获取'ad accounts'和'ads performance'

提问于
浏览
1

虽然我不知道该程序,但我知道可以使用相同的令牌:

  • 列出您用户下的所有广告帐户

  • 获取每个广告系列的广告效果信息

此外,令牌不是短期令牌(不需要每24小时刷新一次)

我尝试使用curl生成一个长生命令牌,如下所示,在bash中以Facebook developers support page中所述:

curl https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id=$client_id&client_secret=$client_secret&fb_exchange_token=$fb_exchange_token

但得到了回应:

“error”:{“message”:“缺少client_id参数 . ”,“type”:“OAuthException”,“code”:101

如果我试图生成的长期令牌是正确的方法:我做错了什么?如果没有,我该如何检索该令牌?

2 回答

  • 0

    我可以在你的网址中看到 client_id 参数 . 而且你的网址中也有 & 字符 . 如果你没有用引号 "' 包装url,那么它将破坏 & 字符处的命令 . 这意味着,您的命令执行如下,因此缺少client_id:

    curl https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token
    

    正确的方法应该是:

    curl "https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id=$client_id&client_secret=$client_secret&fb_exchange_token=$fb_exchange_token"
    
  • 0

    如果广告帐户和广告代码是长期令牌或生命周期令牌,则相同的令牌可用于广告帐户和广告效果 . 生命周期令牌可以通过使用60天令牌发出另一个请求来实现 .

    执行以下curl以获取持久(2个月)访问令牌:

    卷曲“https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id= $ client_id&client_secret = $ client_secret&fb_exchange_token = $ fb_exchange_token”

    其中:client_id - App ID client_secret - App secret fb_exchange_token - 临时令牌 .

    注意:确保您使用的是在过去12小时内创建的临时令牌

    终身令牌

    使用地址/ me / accounts粘贴FB Graph API Explorer中的持久访问令牌

    使用其中显示的其中一个令牌 .

相关问题