How to set permission "publish_actions" in LoginButton using facebook sdk?

hiein2003 picture hiein2003 · Sep 17, 2014 · Viewed 10.2k times · Source

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.

Answer

andyrandy picture andyrandy · Sep 17, 2014

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.