我正在使用facebook4j在我的Facebook牆上發送帖子。在這樣做的時候,我面臨着一個錯誤。在我的控制檯中顯示的錯誤是運行我的代碼時。我檢查了我的appid
,appSecret
和accesstoken
這些值也是正確的。使用java集成Facebook
這裏是我用來發送消息的代碼:
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}}
', [email protected]35678, 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)
有人能指出我的錯誤?
您必須直接從Facebook請求訪問令牌... – MadProgrammer
您好,我遇到同樣的錯誤,您是否發現了facebook4j的解決方案? – jNick