2

I am trying to post a message onto a facebook group (I am the admin for the page). Here is the java code that I am using:

public void makeTestPost() {
        fbClient = new DefaultFacebookClient(groupPageAccessToken);
        counter = 0;
        fbClient.publish(groupID + "/posts", FacebookType.class, Parameter.with("message", Integer.toString(counter) + ": Hello, fb World!"));
        counter++;
    }

with:

private final string groupPageAccessToken = "XXXXXXXXXXXXXXXXXX";
private final String groupID = "XXXXXXX";

I got these values using the facebook graph explorer api online Graph API Explorer

But when I login to facebook I don't see any message/post on the group. Please tell me how to make it work?

nitin goel
  • 21
  • 1

1 Answers1

0

You need an user access token with the permissions publish_actions and user_managed_groups.

Then you can publish a new message like this:

GraphResponse response = fbClient.publish(groupID + "/feed", GraphResponse.class, Parameter.with("message", Integer.toString(counter) + ": Hello, fb World!"));
Norbert
  • 1,391
  • 1
  • 8
  • 18