Невозможно опубликовать на стене Facebook с помощью Facebook4J Java - PullRequest
0 голосов
/ 13 апреля 2019

Я пытаюсь опубликовать сообщение на Facebook, используя библиотеку facebook 4j.Может кто-нибудь помочь, что не так в коде ниже?

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)
...