How to set permission “publish_actions” in LoginButton using facebook sdk?

本秂侑毒 提交于 2019-12-24 03:44:12

问题


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:


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.



来源:https://stackoverflow.com/questions/25888465/how-to-set-permission-publish-actions-in-loginbutton-using-facebook-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!