-1

I am trying to post a message on my facebook wall using Java. I have marked all the permissions. But I am getting the exception "FacebookOAuthException". Kindly help in resolving this. Thanks in advance!

package com.java.sample.workouts;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

import com.restfb.DefaultFacebookClient;
import com.restfb.FacebookClient;
import com.restfb.Parameter;
import com.restfb.Version;
import com.restfb.types.FacebookType;
import com.restfb.types.User;
import com.sun.media.jfxmedia.logging.Logger;

public class PostInFBWall {

    public static void updateStatus(String message) {
        FacebookClient facebookClient= new DefaultFacebookClient("access token", Version.LATEST);
         facebookClient.publish("me/feed", FacebookType.class,
                 com.restfb.Parameter.with("message", message));
    }

    public static void main(String[] args) {
        PostInFBWall.updateStatus("FB testing");
    }
}

And the screenshot of facebook permission is:

Facebook permissions

And the exception in eclipse is:

Exception in thread "main" com.restfb.exception.FacebookOAuthException: Received Facebook error response of type OAuthException: (#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 (code 200, subcode null)
at com.restfb.DefaultFacebookClient$DefaultGraphFacebookExceptionMapper.exceptionForTypeAndMessage(DefaultFacebookClient.java:1199)
at com.restfb.DefaultFacebookClient.throwFacebookResponseStatusExceptionIfNecessary(DefaultFacebookClient.java:1116)
at com.restfb.DefaultFacebookClient.makeRequestAndProcessResponse(DefaultFacebookClient.java:1057)
at com.restfb.DefaultFacebookClient.makeRequest(DefaultFacebookClient.java:979)
at com.restfb.DefaultFacebookClient.publish(DefaultFacebookClient.java:453)
at com.restfb.DefaultFacebookClient.publish(DefaultFacebookClient.java:478)
at com.java.sample.workouts.PostInFBWall.updateStatus(PostInFBWall.java:35)
at com.java.sample.workouts.PostInFBWall.main(PostInFBWall.java:52)
Kutty
  • 712
  • 1
  • 5
  • 22

1 Answers1

0

Publishing messages or photos to your user wall is not possible anymore, the required permission would have been publish_actions, but it is deprecated.

andyrandy
  • 72,880
  • 8
  • 113
  • 130