需要OAuthException代码2500的帮助 [英] Need Help on OAuthException Code 2500
问题描述
我正在尝试使用PHP开发一个Facebook应用程序(apps.facebook.com/some_app),我需要根据用户的音乐兴趣提供一些信息。我发现它在user_likes>游戏下。
I am trying to develop an Facebook application (apps.facebook.com/some_app) using PHP where I need to present some information based on user's music interests. I found that its under "user_likes > games".
我的问题如下:
- 要获得访问权限,我已经在我的索引页面中将API实现了oauth对话框方法
。
$auth_url = "http://www.facebook.com/dialog/oauth?client_id="
. $app_id . "&redirect_uri="
. urlencode($canvas_page)
."&scope=user_likes";
- 成功授权后,我回到使用code的索引页
作为参数。
http://MY_CANVAS_PAGE/?code=some base64 encoded letters
- 不知道我是否需要access_token只是为了阅读用户的音乐
兴趣,但我已经尝试了所有的方法建议。我不能从这一点向前移动
- 我有一个这样的代码(在我的索引页面中),如果未设置代码参数,则重定向以进行授权。 li>
- Firstly I don't know if I need access_token just to read user's music interests but I have tried all the methods suggested. I couldn't move forward from this point
- I have a code like this (in my index page), which redirects for authorization if code parameters is not set.
if(empty($code) && !isset($_REQUEST['error'])) { $_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection echo("<script> top.location.href='" . $auth_url . "'</script>"); }
- 目前我只是想让用户公开信息在这里,但
没有成功。我已经尝试使用signed_request方法建议
但没有成功
$signed_request = $_REQUEST["signed_request"]; list($encoded_sig, $payload) = explode('.', $signed_request, 2); $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true); echo ("Welcome User: " . $data["user_id"]);
-
还尝试在
< a href =http://developers.facebook.com/blog/post/500/ =noreferrer> http://developers.facebook.com/blog/post/500/但是,尝试使用
print_r($decoded_response);
stdClass Object ( [error] => stdClass Object ( [message] => An active access token must be used to query information about the current user. [type] => OAuthException [code] => 2500 ) )
为了获取用户的公共信息,我也尝试了PHP中的建议示例SDK
To get user's public info, I have tried also the suggested example in PHP SDK
$facebook = new Facebook(array( 'appId' => MY_APP_ID, //registered facebook APP ID 'secret' => MY_SECRET, //secret key for APP )); $fb_user = $facebook->getUser(); if($fb_user){ try { $user_profile = $facebook->api('/me'); echo $user_profile['email']; } catch(FacebookApiException $e) { $fb_user = null; } }
但没有成功。有人可以解释一下为什么我收到这个错误,以及如何正确地访问用户的音乐兴趣。可能我误解了API。
But no success. Can somebody explain me why I am getting this error and how to access the user's music interest properly. Probably I misunderstood the API.
谢谢
Deepak
推荐答案
错误2500表示您没有访问令牌或应用访问令牌,但尝试访问
/ me /
- '我'是'当前用户或页面ID'的占位符,所以如果没有用户或页面的访问令牌,则不会生效。Error 2500 means you have no access token or an app access token but are trying to access
/me/
- 'me' is a placeholder for 'current user or page ID' so won't be valid without an access token for a user or page.要访问用户的列表您还需要
user_likes
许可当他们授权他们To access the user's list of likes you'll also need the
user_likes
Permission when authorising them最可能的原因,我看到的应用程序无法交换
代码
用于访问令牌是:The most likely causes i've seen for apps not being able to exchange the
code
for an access token are:- 您使用的
redirect_uri
是一个文件夹或服务器根目录,并且缺少尾部斜杠(即它是http://www.example.com
而不是http://www.example。 com /
) -
redirect_uri
您在第一次调用auth对话框中使用的内容与用于访问access_token的代码中使用的redirect_uri
不完全相同
- The
redirect_uri
you used is to a folder or server root and is missing a trailing slash (i.e it'shttp://www.example.com
instead ofhttp://www.example.com/
) - The
redirect_uri
you used in the first call to the auth dialog wasn't precisely the same as theredirect_uri
you used in the call to exchagne the code for an access_token
如果您的验证流由于其他原因而损坏,您无法从SDK示例或身份验证文档,这可能需要一段时间才能让人与您交流,因为您可能会缺少必要的背景知识了解他们的答案
If your auth flow is broken for some other reason and you can't figure it out from the SDK examples or the Authentication documentation, this could take a while for someone to talk you through because you may be missing some background knowledge necessary to understand their answers
这篇关于需要OAuthException代码2500的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- 您使用的