不退换许可publish_actions:Facebook的SDK 3.8 [英] Facebook SDK 3.8 : permission publish_actions not returned

查看:429
本文介绍了不退换许可publish_actions:Facebook的SDK 3.8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下面的Facebook的机器人共享教程被Facebook(<一href="https://developers.facebook.com/docs/android/share">https://developers.facebook.com/docs/android/share).该应用程序运行正常,我可以用Facebook登录的演示分享按钮的点击所以这是我的应用程序的过程:

I'm following the facebook android sharing tutorial by facebook (https://developers.facebook.com/docs/android/share). The app runs fine and I can login with facebook an click on the demo share button. So this is the procedure of my app:

  1. 在登录facebook
  2. 在Facebook的会话对象得到更新和下面的权限将被保存在session对象中: user_likes,user_friends,user_status,basic_info
  3. 现在,我想分享的东西。因此,用户点击分享按钮和 publish_actions 称为一个额外的权限发出请求
  1. Login with facebook
  2. The facebook session object gets updated and the following permissions are saved within the session object: user_likes, user_friends, user_status, basic_info
  3. Now, I want to share something. Therefore the user clicks on a share button and a request for an additional permission called publish_actions is made

下面code执行这一要求:

The following code performs this request:

public class MainActivity extends Activity {

    private Button shareButton;
    private UiLifecycleHelper uiHelper;
    private static final List<String> PERMISSIONS = Arrays.asList("publish_actions");
    private static final String PENDING_PUBLISH_KEY = "pendingPublishReauthorization";
    private boolean pendingPublishReauthorization = false;

...
    private void publishStory() {
        Session session = Session.getActiveSession();
        if( session != null) {
            List<String> permissions = session.getPermissions();
            if(!isSubsetOf(PERMISSIONS, permissions)) {
                pendingPublishReauthorization = true;
                Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(this, PERMISSIONS);
//Request the new permission here. The answer is processed in onSessionStateChange() method
                session.requestNewPublishPermissions(newPermissionsRequest);
                return;
            }

...

    private void onSessionStateChange(Session session, SessionState state, Exception exception) {
//since the session is already open we enter this if branch
        if (state.isOpened()) {
            shareButton.setVisibility(View.VISIBLE);
//The result of state.equals(SessionState.OPENED_TOKEN_UPDATED) is false which indicates that the session object has not been updated (as far as I understand the fb api)
            Log.e(TAG, "state.equals(SessionState.OPENED_TOKEN_UPDATED) = " + state.equals(SessionState.OPENED_TOKEN_UPDATED));
//Output all the current permission the session has (publish_actions is not included here)
            List<String> permissions = session.getPermissions();
            Iterator<String> it = permissions.iterator();
            Log.e(TAG, "Content of list:");
            while(it.hasNext())
                Log.e(TAG, "permission = " + it.next());
//Since the OPENED_TOKEN_UPDATED has not been updated nothing further happens here              
            if (pendingPublishReauthorization && state.equals(SessionState.OPENED_TOKEN_UPDATED)) {
                pendingPublishReauthorization = false;
                publishStory();
            }
        } else if (state.isClosed()) {
            shareButton.setVisibility(View.INVISIBLE);
        }
    }

因此​​,虽然这似乎是正确的,必须有一些剩余的错误。该publish_actions不被许可,但是我不明白为什么。只有现有的权限仍然 publish_actions

另外一句话:我读过,说一个额外的弹出应该出现要求用户授予权限的一些问题。然而,这不会发生在我的情况。也许这是什么问题?如果是这样,我有什么做的就是弹出窗口?

Further remark: I've read some questions that say that an additional popup should appear asking the user to grant the permission. However this does not happen in my case. Maybe this is the problem? If so, what do I have to do to get the popup window?

更新:我也尝试另外从github上以下要点: https://gist.github.com/vishalpawale/5556996 此示例code由于失败的确切同样的原因。它没有得到任何publish_action许可。似乎是在Facebook的SDK中有一个实际的错误?

UPDATE: I also additionally tried the following gist from github: https://gist.github.com/vishalpawale/5556996 This sample code fails due to the exact same reason. It does not get any publish_action permission. Seems to be a actual bug in the Facebook SDK?

推荐答案

有关发布,你应该在应用程序设置发送请求和发送审查许可,看到的 https://developers.facebook.com/docs/apps/review/

For publish permission you should send request in app settings and send for review, see https://developers.facebook.com/docs/apps/review/

这篇关于不退换许可publish_actions:Facebook的SDK 3.8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆