How to set permission “publish_actions” in LoginBu

2019-07-15 12:18发布

I want to post a picture on facebook timeline. I am using LoginButton to set up the permission of publish_actions.But I got error message

 "com.facebook.FacebookException: Cannot pass a publish or manage permission (publish_actions) to a request for read authorization." 

Does any one know how to set the permission in LoginButton?

protected void onCreate(Bundle savedInstanceState) {    
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(savedInstanceState);
    LoginButton  loginButton = (LoginButton) findViewById(R.id.loginButton);
    loginButton.setReadPermissions(Arrays.asList
              ("publish_actions","user_friends", "email" , "user_photos" ));
    loginButton.setTextColor(Color.TRANSPARENT);
    loginButton.setCompoundDrawablesWithIntrinsicBounds(0,0,0,0);
    loginButton.setBackgroundResource(R.drawable.fb);

}

Any suggestion will be appreciated.

1条回答
女痞
2楼-- · 2019-07-15 13:12

You cannot add publish permissions with setReadPermissions as it seems. There is a pretty good answer in this thread: Facebook, setReadPermissions and setPublishPermissions

Basically, you should not ask for read and write permissions at the same time. Apps should not post something on the user wall directly after login anyway - only on specific User interaction.

查看更多
登录 后发表回答