我正试图通过https://graph.facebook.com/FACEBOOK_USER_ID/feed?access_token=MY_FACEBOOK_APP_ACCESS_TOKEN
使用Graph API获取Facebook个人资料供稿(墙)信息当我从浏览器访问上述URL时,我能够成功检索用户的Facebook墙信息,如下所示:
{
data: [
{
id: "",
from: {
name: ",
id: ""
}}]}
但是我从Java代码访问相同的URL时收到OAuthException。 我的Java代码是:
String fbURL = "https://graph.facebook.com/"+FACEBOOK_USER_ID+"/"+
"feed?access_token="+MY_FACEBOOK_APP_ACCESS_TOKEN;
HttpClient httpclient = new HttpClient();
PostMethod post = new PostMethod(fbURL);
httpclient.executeMethod(post);
String response = post.getResponseBodyAsString();
当我尝试打印响应json时,我得到了
{"error":{"message":"(#200) The user hasn't authorized the application to perform this action","type":"OAuthException","code":200}}
为什么会这样?当我从浏览器访问https://graph.facebook.com/FACEBOOK_USER_ID/feed?access_token=MY_FACEBOOK_APP_ACCESS_TOKEN时,我得到了正确的响应JSON。但是从java代码执行时我收到了OAuth异常。
有谁能告诉我我做错了什么?
谢谢。