我想在朋友的墙上发帖子,我得到了我的朋友列表和他们的身份证现在我正在使用下面的代码,但它没有发布任何消息给我的朋友墙,我会发布我的代码,在我的上面的代码我正在使用我的朋友的静态ID,但它没有在我的朋友墙上发布任何消息,如果我用我的fb id替换id然后它发布在我的墙上?
private void getfriendlist()
{
Session.openActiveSession(this, true, new Session.StatusCallback()
{ // callback when session changes state @SuppressWarnings("deprecation")
@Override
public void call(final Session session, SessionState state, Exception exception) { if(session.isClosed())
{
Log.i("postStatusUpdate session.isClosed", "message not posted session is closed");
} if (session.isOpened())
{ // Log.i("session.isOpened", "session.isOpened"); //session.requestNewReadPermissions(newPermissionsRequest);
if (!session.isOpened())
{ Session.OpenRequest openRequest = null;
openRequest = new Session.OpenRequest(InvitefriendsActivity.this);
if (openRequest != null) { //openRequest.setDefaultAudience(SessionDefaultAudience.FRIENDS); openRequest.setPermissions(Arrays.asList("email,user_birthday,user_location,user_hometown,user_about_me,user_relationships,publish_stream,publish_actions,basic_info,status_update","friends_birthday","read_friendlists")); //openRequest.setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK); session.openForRead(openRequest);
} }
Request.executeMyFriendsRequestAsync(session, new Request.GraphUserListCallback()
{
@Override public void onCompleted(List<GraphUser> users, Response response) { Log.d("AL",""+response.toString());
for (int i=0;i<users.size();i++)
{ //Log.d("AL",""+users.get(i).toString());
Log.d("AL",""+users.get(i).getId());
Log.d("AL",""+users.get(i).asMap().get("name"));
Bundle params = new Bundle();
params.putString("message", "Hi ");
params.putString("caption", "Hello");
Request request = new Request(session, "100005147887121/feed", params, HttpMethod.POST); RequestAsyncTask task = new RequestAsyncTask(request); task.execute(); } } }); } } }); }
答案 0 :(得分:1)
我认为这与请求的权限有关。你(你的会话)是否允许发布给别人Wall?您可以在此处找到可用权限列表
https://developers.facebook.com/docs/reference/login/extended-permissions/
我认为您需要申请'publish_actions'
此致
迈克尔