2013-05-02 82 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

相关问题