2012-04-17 166 views
11

我需要延長我的facebook訪問令牌,我打電話這樣的:擴展Facebook的頁面訪問令牌

https://graph.facebook.com/oauth/access_token? 
client_id={MY PAGE ID}& 
client_secret={THE SECRET KEY OF MY APP}& 
grant_type=fb_exchange_token& 
fb_exchange_token={AN ACCESS TOKEN FOR MY PAGE} 

,我得到這個錯誤:

"error": { 
     "message": "Error validating application. Cannot get application info due to a system error.", 
     "type": "OAuthException", 
     "code": 101 
    } 

我見過很多與access_token有關的問題,但沒有回答相對於頁面,idk爲什麼facebook使用api,爲什麼......但是這樣...

謝謝

+0

你已經解決了嗎? – 2012-06-21 09:02:20

+0

我也希望來自Facebook開發團隊的人能夠提供適當的解決方案,因爲我們現在面臨同樣的問題。 – 2012-09-20 02:21:46

回答

21

要獲得長期的訪問令牌,你需要遵循這些步驟:

  1. 創建應用程序
  2. 創建專頁(您的帳戶必須是「管理員」頁面)
  3. 將應用程序關聯到頁面(與將頁面標籤頁添加到頁面時相同)

    http://facebook.com/add.php?api_key=*YOUR_APP_ID*&pages=1&page=*YOUR_PAGE_ID* 
    
  4. 獲取具有與您的應用程序關聯的權限「manage_pages」的短期訪問令牌。

    https://graph.facebook.com/oauth/authorize?client_id=__APP_ID__&scope=manage_pages&redirect_uri=http://www.facebook.com/connect/login_success.html 
    then 
    https://graph.facebook.com/oauth/access_token?client_id=__APP_ID__&redirect_uri=http://www.facebook.com/connect/login_success.html&client_secret=__APP_SECRET__&code=__CODE_FROM_PREVIOUS_REQUEST__ 
    
  5. 使用圖形API瀏覽器與/me/accounts可以看到訪問令牌,你是管理員爲每個頁面的請求。問題在於那些訪問令牌是短暫的。

  6. 將您短暫的訪問令牌長壽命(延長訪問令牌):

    https://graph.facebook.com/oauth/access_token?client_id=_APP_ID_&client_secret=_APP_SECRET_&grant_type=fb_exchange_token&fb_exchange_token=_ACCESS_TOKEN_ON_STEP_4_ 
    
  7. 您現在可以測試與Access Token Debugger新的訪問令牌。

+0

問題:我的應用程序不是'選項卡應用程序'我如何關聯它? – siniradam 2013-03-11 12:35:31

+1

@siniradam使用此網址:http://facebook.com/add.php?api_key=*YOUR_APP_ID*&pages=1&page=*YOUR_PAGE_ID* – FR6 2013-03-11 15:08:12

+0

謝謝。順便說一句昨天我發現,如果我向長期令牌/我/賬戶發送請求,列表返回帶有長期令牌。我已經測試過這個:https://developers.facebook.com/tools/debug/access_token?q = – siniradam 2013-03-12 08:14:32

2

Scenario 5: Page Access Tokens

When a user grants an app the manage_pages permission, the app is able to obtain page access tokens for pages that the user administers by querying the [User ID]/accounts Graph API endpoint. With the migration enabled, when using a short-lived user access token to query this endpoint, the page access tokens obtained are short-lived as well.

Exchange the short-lived user access token for a long-lived access token using the endpoint and steps explained earlier. By using a long-lived user access token, querying the [User ID]/accounts endpoint will now provide page access tokens that do not expire for pages that a user manages. This will also apply when querying with a non-expiring user access token obtained through the deprecated offline_access permission.

https://developers.facebook.com/roadmap/offline-access-removal/