Facebook PHP API 订阅问题
我正在尝试按照此处所述使用 Facebook 的实时更新。我正在使用 PHP SDK。我已经拥有一个可用于具有以下权限的其他功能的访问令牌:user_checkins、publish_stream、offline_access。
尝试添加订阅时,我从 Facebook SDK 收到以下错误。
致命错误:未捕获 OAuthException:(#15) 必须使用应用程序 access_token 调用此方法
我正在使用的代码如下。所有变量均设置正确。有什么想法吗?
$callback_url = plugins_url('fb_callback.php',__FILE__);
$config = array('appId' => $app_id,
'secret' => $app_secret,
);
$facebook = new Facebook($config);
$token = fb_get_access_token();
$facebook->setAccessToken($token);
$ret_obj = $facebook->api($app_id . '/subscriptions', 'POST',
array('callback_url' => $callback_url,
'object' => 'checkin',
'verify_token' => 'a390jkl091091j908j',
'fields' => 'id'
));
I'm trying to use Facebook's realtime updates as described here. I'm using the PHP SDK. I already have an access token that works for other functions with these permissions: usser_checkins,publish_stream,offline_access.
When trying to add the subscription I receive the following error from the Facebook SDK.
Fatal error: Uncaught OAuthException: (#15) This method must be called with an app access_token
The code I am using is below. All the variables are set correctly. Any ideas?
$callback_url = plugins_url('fb_callback.php',__FILE__);
$config = array('appId' => $app_id,
'secret' => $app_secret,
);
$facebook = new Facebook($config);
$token = fb_get_access_token();
$facebook->setAccessToken($token);
$ret_obj = $facebook->api($app_id . '/subscriptions', 'POST',
array('callback_url' => $callback_url,
'object' => 'checkin',
'verify_token' => 'a390jkl091091j908j',
'fields' => 'id'
));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我用示例代码写了一篇文章,其中包含此问题的解决方案:
http://marcneuwirth.com/blog/2011/12/08/facebook-real-time-updates/
希望有帮助。
I wrote a post with my solution for this problem with example code:
http://marcneuwirth.com/blog/2011/12/08/facebook-real-time-updates/
Hopefully that helps.
我有类似的问题。不确定是否和你的一样。但是,只有当且仅当请求 URI 的查询字符串中没有“范围”时,应用访问令牌才会按预期返回。换句话说,它需要准确无误:
如果与上面不同,它将返回用户访问令牌,即使使用
&grant_type=client_credentials
I had a similar issue. Not sure if it's the same as yours. But, the app access token is only returned as expected if, and only if, the request URI do not have the "scope" on the querystring. In other words, it need to be exactly:
If it's different from the above, it will return the user access token, even with the
&grant_type=client_credentials