简体   繁体   中英

Facebook post in group wall using Graph API

I'm developing a android application which is requires posting in groups created by the user.

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.

Can anyone help me in solving the above said two issues.

Thanks.

By default, the fb.request method uses a GET request. As you are intending to create a new post, you need to use the POST method. Doing this is simple - just pass a third argument ( httpMethod ) as "POST".

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

For more info: 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

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.

second argument bundle is the bundle which you want to passed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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