久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

需要有關 OAuthException 代碼 2500 的幫助

Need Help on OAuthException Code 2500(需要有關 OAuthException 代碼 2500 的幫助)
本文介紹了需要有關 OAuthException 代碼 2500 的幫助的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試使用 PHP 開發 Facebook 應用程序 (apps.facebook.com/some_app),我需要根據用戶的音樂興趣提供一些信息.我發現它在user_likes > games"下.

我的問題如下:

  • 為了獲得訪問權限,我已將 oauth 對話框方法實現為在我的索引頁面的 API 中建議.
<小時>

$auth_url = "http://www.facebook.com/dialog/oauth?client_id=".$app_id ."&redirect_uri=".urlencode($canvas_page)."&scope=user_likes";

  • 授權成功后,我回到帶有代碼"的索引頁面作為參數.
<小時>

http://MY_CANVAS_PAGE/?code=一些 base64 編碼的字母

  • 首先我不知道我是否需要 access_token 來讀取用戶的音樂興趣,但我已經嘗試了所有建議的方法.我動不了從這里開始
  • 我有一個這樣的代碼(在我的索引頁面中),如果沒有設置代碼參數,它會重定向以進行授權.
<小時>

if(empty($code) && !isset($_REQUEST['error'])) {$_SESSION['state'] = md5(uniqid(rand(), TRUE));//CSRF保護echo("<script> top.location.href='" . $auth_url . "'</script>");}

  • 目前我只是想在這里獲取用戶的公開信息,但是沒有成功.我已經按照建議嘗試了 signed_request 方法但沒有成功
<小時>

$signed_request = $_REQUEST["signed_request"];列表($encoded_sig, $payload) = expand('.', $signed_request, 2);$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);echo ("歡迎用戶:" . $data["user_id"]);

  • 還嘗試了在http://developers.facebook.com/blog/post/500/>

    但是在嘗試使用

  • 獲取調試信息時出現錯誤
<小時>

print_r($decoded_response);

<小時>

stdClass Object ( [error] => stdClass Object ( [message] => 一個活動必須使用訪問令牌來查詢有關當前用戶的信息.[類型] =>OAuthException [代碼] =>2500 ) )

為了獲取用戶的公開信息,我也嘗試了 PHP SDK 中的建議示例

<小時>

$facebook = new Facebook(array('appId' =>MY_APP_ID,//注冊的facebook APP ID'秘密' =>MY_SECRET,//APP的秘鑰));$fb_user = $facebook->getUser();如果($ fb_user){嘗試 {$user_profile = $facebook->api('/me');回聲 $user_profile['email'];}抓住(FacebookApiException $e){$fb_user = null;}}

但沒有成功.有人可以解釋我為什么會收到此錯誤以及如何正確訪問用戶的音樂興趣.可能我誤解了 API.

謝謝

Deepak

解決方案

Error 2500 表示您沒有訪問令牌或應用程序訪問令牌但正在嘗試訪問 /me/ - 'me' 是當前用戶或頁面 ID"的占位符,因此在沒有用戶或頁面的訪問令牌的情況下無效.

要訪問用戶的喜歡列表,您還需要 user_likes 權限 授權他們

我見過的應用程序無法將 code 交換為訪問令牌的最可能原因是:

  1. 您使用的 redirect_uri 指向文件夾或服務器根目錄,并且缺少尾部斜杠(即它是 http://www.example.com 而不是 http://www.example.com/)
  2. 您在第一次調用身份驗證對話框時使用的 redirect_uri 與您在調用中用于交換 access_token 代碼的 redirect_uri 并不完全相同

如果您的身份驗證流程因其他原因而中斷,并且您無法從 SDK 示例或 身份驗證 文檔,這可能需要一段時間才能讓某人與您交談,因為您可能缺少理解他們的答案所必需的一些背景知識

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".

My problems are as follows:

  • To gain access, I have implemented the oauth dialog method as suggested in API in my index page.

$auth_url = "http://www.facebook.com/dialog/oauth?client_id="
            . $app_id . "&redirect_uri=" 
            . urlencode($canvas_page)
            ."&scope=user_likes";

  • After successful authorization I come back to index page with "code" as parameters.

http://MY_CANVAS_PAGE/?code=some base64 encoded letters

  • 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>");
}

  • Currently I am just trying to get user's public information here but with no success. I have tried the signed_request method as suggested but no success

$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"]);

  • Also tried the code found in http://developers.facebook.com/blog/post/500/

    but I am getting error when trying to get the debug info using


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 ) ) 

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;
    }
}

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.

Thanks

Deepak

解決方案

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.

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:

  1. The redirect_uri you used is to a folder or server root and is missing a trailing slash (i.e it's http://www.example.com instead of http://www.example.com/)
  2. The redirect_uri you used in the first call to the auth dialog wasn't precisely the same as the redirect_uri you used in the call to exchagne the code for an access_token

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 的幫助的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 欧美二区在线 | 免费xxxx大片国产在线 | 91视频进入| 久久国产传媒 | 亚洲精品一区二区三区在线观看 | 中文字幕视频在线观看 | 欧美精品一区在线发布 | 最新中文字幕在线 | 久久久久精 | 99婷婷 | 精品一二区 | 色橹橹欧美在线观看视频高清 | 亚洲精品久久久一区二区三区 | 久久久久久久av麻豆果冻 | 欧美成人影院在线 | 超碰电影 | 伊人久久综合 | 国内精品久久久久久 | 国产精品a久久久久 | 91短视频网址 | 99在线精品视频 | 国产成人精品一区二区三区网站观看 | 欧美日韩精品免费观看 | 欧美视频一区二区三区 | 玖玖玖在线 | 久久精品国产一区二区电影 | 99福利视频导航 | 国产网站在线免费观看 | hsck成人网 | 日韩在线电影 | 99久久成人 | 一级片网站视频 | 国产成人免费 | 亚洲综合国产 | 一区二区视屏 | 欧美在线观看一区二区 | 亚洲成色777777在线观看影院 | 九九爱这里只有精品 | 亚洲 欧美 日韩在线 | 国产视频福利在线观看 | 久久国产精品99久久久久 |