我正在使用 facebook4j 在我的 Facebook 墙上发送帖子。这样做时,我面临一个错误。我的控制台中显示的错误是在运行我的代码时。我检查了我的appid
,appSecret
和accesstoken
值也是正确的。
这是我用来发送消息的代码:
public static void sendMessage(){
Facebook facebook = new FacebookFactory().getInstance();
String appId = "XXXXX";
String appSecret = "XXXXXXXXXXX";
facebook.setOAuthAppId(appId, appSecret);
String commaSeparetedPermissions ="user_friends,user_groups,user_photos,user_videos,user_birthday,user_status,user_likes,user_activities,user_location";
facebook.setOAuthPermissions(commaSeparetedPermissions);
String accessToken = "XXXXXXXXXXXXXX";
facebook.setOAuthAccessToken(new AccessToken(accessToken, null));
try {
facebook.postStatusMessage("Hello World from Facebook4J From Java Programming....");
} catch (FacebookException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
我在控制台中收到以下错误:
FacebookException [statusCode=400, response=HttpResponse{statusCode=400, responseAsString='{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}
', is=sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@335678, streamConsumed=true}, errorType=OAuthException, errorMessage=An active access token must be used to query information about the current user., errorCode=2500]
at facebook4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:189)
有人可以指出我的错误吗?