简体   繁体   English

使用Graph API在群组墙上的Facebook帖子

[英]Facebook post in group wall using Graph API

I'm developing a android application which is requires posting in groups created by the user. 我正在开发一个Android应用程序,该应用程序需要按用户创建的组进行发布。

Bundle params = new Bundle();
params.putString("link","www.google.com");
params.putString("message","Group Message");

try {
  String res =    fb.request(GROUP_ID+"/feed",params);

 Log.w("Response",""+res);
} catch (MalformedURLException e) {

 e.printStackTrace();
 } catch (IOException e) {
 e.printStackTrace();
}

 }

Also i'm using the following permissions, 另外我正在使用以下权限,

public static final String[] permissions = {"user_photos","friends_groups","read_stream","user_groups","publish_stream"};

But when i execute this, no exception is raised and the post is not made in the group's wall. 但是,当我执行此操作时,不会引发任何异常,并且不会在组的墙上发布该帖子。

When i tried to create @Mentions using, @[user_id:name] i'm not even getting the hyperlinks. 当我尝试使用@[user_id:name]创建@Mentions时,我什至没有得到超链接。

Can anyone help me in solving the above said two issues. 谁能帮助我解决上述两个问题。

Thanks. 谢谢。

By default, the fb.request method uses a GET request. 默认情况下, fb.request方法使用GET请求。 As you are intending to create a new post, you need to use the POST method. 当您打算创建一个新帖子时,您需要使用POST方法。 Doing this is simple - just pass a third argument ( httpMethod ) as "POST". 这样做很简单-只需将第三个参数( httpMethod )传递为“ POST”即可。

For example: String res = fb.request(GROUP_ID+"/feed",params,"POST"); 例如: String res = fb.request(GROUP_ID+"/feed",params,"POST");

For more info: https://developers.facebook.com/docs/reference/androidsdk/ayncrequest/ 有关更多信息: https : //developers.facebook.com/docs/reference/androidsdk/ayncrequest/

Also, the first argument needs to be a full URL, not just an ID - https://graph.facebook.com/GROUP_ID/feed 另外,第一个参数必须是完整的URL,而不仅仅是ID- https://graph.facebook.com/GROUP_ID/feed

Of course, I'm making an assumption based on your variable name. 当然,我要根据您的变量名进行假设。

String response = mFacebook.request(GROUP_ID+"/feed",bundle,"POST");

by using the above method we can post at group wall. 通过使用以上方法,我们可以在组墙张贴。 first argument GROUP_ID should be a string which is numeric having 15 digits.It should not be a url. 第一个参数GROUP_ID应该是包含15位数字的数字字符串,而不应该是url。

second argument bundle is the bundle which you want to passed. 第二个参数捆绑是您要传递的捆绑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM