[英]How to post in a group on facebook using restfb?
I am trying to post a message onto a facebook group (I am the admin for the page). 我正在尝试将消息发布到Facebook组(我是该页面的管理员)。 Here is the java code that I am using:
这是我正在使用的Java代码:
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 我使用facebook graph graph Explorer API在线Graph API Explorer获得了这些值
But when I login to facebook I don't see any message/post on the group. 但是,当我登录Facebook时,该群组上没有任何消息/帖子。 Please tell me how to make it work?
请告诉我如何使其工作?
You need an user access token with the permissions publish_actions
and user_managed_groups
. 您需要具有权限
publish_actions
和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!"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.