【发布时间】: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