2013-05-02 83 views
0

1)我試圖讓一個訪問令牌,我的應用程序如docs描述:Facebook:如何將應用測試用戶設置爲朋友?

To obtain an App Access Token, invoke the following HTTP GET request 

GET https://graph.facebook.com/oauth/access_token? 
      client_id=YOUR_APP_ID 
      &client_secret=YOUR_APP_SECRET 
      &grant_type=client_credentials 

The API will respond with a query-string formatted string of the form: 

    access_token=YOUR_APP_ACCESS_TOKEN 

我得到一個奇怪的分流標誌訪問令牌|結果如下:

access_token=568852943149232|ah1X8cAXHKSvFrTrZ4XybG0GzR4 

這似乎與文檔有衝突,因爲第一個參數是app_id(在符號|之前)。

2)然後我嘗試用奇怪的access_token得到朋友的訪問令牌(它需要使無形的測試用戶的朋友):

https://graph.facebook.com/APP_ID/accounts/test-users?access_token=568852943149232|ah1X8cAXHKSvFrTrZ4XybG0GzR4

它返回:

{ 
    "error": { 
     "message": "(#803) Some of the aliases you requested do not exist: APP_ID", 
     "type": "OAuthException", 
     "code": 803 
    } 
} 

如果在|之前刪除部分(包括符號|)和使另一個請求,則返回另一個錯誤:

{ 
    "error": { 
     "message": "Invalid OAuth access token.", 
     "type": "OAuthException", 
     "code": 190 
    } 
} 

3)結果我需要從一個用戶和響應來自另一個做出「朋友」的請求(描述here):

https://graph.facebook.com/USER1_ID/friends/USER2_ID?method=post&access_token=TEST_USER_1_ACCESS_TOKEN 
https://graph.facebook.com/USER2_ID/friends/USER1_ID?method=post&access_token=TEST_USER_2_ACCESS_TOKEN 

我不能這樣做,因爲我無法在步驟2上獲得這些(用戶)訪問令牌。

返回應用程序access_token是否正確?如果是,如何使用它?

Notice please:我從瀏覽器的應用程序所有者處於登錄狀態的地址行進行調用。

回答

2

你需要與你的實際APP_ID

這就是爲什麼你得到這個消息來替換APP_ID。

{ 
    "error": { 
    "message": "(#803) Some of the aliases you requested do not exist: APP_ID", 
    "type": "OAuthException", 
    "code": 803 
    } 
} 

如果您的應用程序ID爲568852943149232和您的應用程序令牌是568852943149232 | ah1X8cAXHKSvFrTrZ4XybG0GzR4然後你的電話是

https://graph.facebook.com/568852943149232/accounts/test-users?access_token=568852943149232|ah1X8cAXHKSvFrTrZ4XybG0GzR4

那的確是你的應用程序令牌容易覈查通過https://developers.facebook.com/tools/access_token

+0

感謝理念。我會測試。 – sergzach 2013-05-02 14:32:16

相關問題