我正在尝试使用facebook 4j库将消息发布到facebook。有人可以帮忙下面的代码出什么问题吗?
public class status{
static String appID = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX";
static String appSecretKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXX";
static String tok = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
public static void update_FB_Status(String appID, String appSecretKey) {
Facebook fb = new FacebookFactory().getInstance();
fb.setOAuthAppId(appID, appSecretKey);
/*fb.setOAuthAccessToken(arg0);*/
fb.setOAuthAccessToken(new facebook4j.auth.AccessToken(tok, null));
try {
fb.postStatusMessage("hello everyone");
} catch (FacebookException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) {
status.update_FB_Status(appID, appSecretKey);
}
我收到以下错误消息:
FacebookException{statusCode=403, errorType='OAuthException', errorMessage='(#200) If posting to a group, requires app being installed in the group, and \
either publish_to_groups permission with user token, or both manage_pages \
and publish_pages permission with page token; If posting to a page, \
requires both manage_pages and publish_pages as an admin with \
sufficient administrative permission', errorCode=200, errorSubcode=-1, version=2.4.6}
at facebook4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:179)
at facebook4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:61)
at facebook4j.internal.http.HttpClientWrapper.post(HttpClientWrapper.java:98)
at facebook4j.FacebookImpl.post(FacebookImpl.java:2887)
at facebook4j.FacebookImpl._postStatusMessage(FacebookImpl.java:2792)
at facebook4j.FacebookImpl.postStatusMessage(FacebookImpl.java:853)
at facebook4j.FacebookImpl.postStatusMessage(FacebookImpl.java:849)