【问题标题】:Facebook Graph-api, premissions for Shares count (Invalid OAuth access token signature)Facebook Graph-api,共享计数的权限(无效的 OAuth 访问令牌签名)
【发布时间】:2016-02-19 00:34:41
【问题描述】:

我离编程和 PHP 还很远,但我遇到了获取网站的 Fb 分享数的挑战 :)

我正在尝试获取正确的应用访问令牌并将请求发送到 Fb 根据this article.

请求应该是这样的:

https://graph.facebook.com/?ids=http://www.myurl.com/my-page&access_token=myappid|myappsecret

我得到了这个错误。

   {
       "error": {
          "message": "Invalid OAuth access token signature.",
          "type": "OAuthException",
          "code": 190,
          "fbtrace_id": "FfZKAkCyad1"
       }
    }

我打算在 PHP 中大致这样使用它:

function facebook_count($url)
{
$results = @file_get_contents('http://graph.facebook.com/' . $url .'&access_token=myappid|myappsecret');
if ($results) {
$like_array = json_decode($results, true);
if (!empty($like_array['shares']))
return ($like_array['shares']);
}

return 0;
}

我的猜测是,我为我的 App 令牌检查了错误的权限(范围)。在 FB 开发页面中没有找到答案。现在检查一下:

user_likes、read_insights、read_audience_network_insights、public_profile

如果我只需要按链接计算的份额,我需要检查什么范围?
或者还有什么问题?

【问题讨论】:

    标签: php facebook facebook-graph-api oauth


    【解决方案1】:

    您需要使用应用访问令牌...所以实际权限(指用户访问令牌!)是无关紧要的。

    因此,希望您将 myappid|myappsecret 替换为您的实际应用 ID 和应用秘密。如果没有,那是你的错误。此外,我认为在file_get_contents 调用中,URL 中的?id= 部分丢失了。

    【讨论】:

      猜你喜欢
      • 2018-09-24
      • 1970-01-01
      • 2011-11-06
      • 1970-01-01
      • 2013-12-04
      • 2019-09-14
      • 2019-04-28
      • 2012-07-24
      • 2013-09-23
      相关资源
      最近更新 更多