使用 Facebook Graph API 时出现错误 - 会话:尝试为具有待处理请求的会话请求新权限

When using Facebook Graph API getting an error - Session: an attempt was made to request new permissions for a session that has a pending request

我有两个申请-

对于第一个应用程序,我已经询问了权限 -

basic_info, email, user_photos, publish_actions

现在,第二个应用程序触发了第一个应用程序[=50=中的BroadcastReceiver ] 以便调用第一个应用程序并尝试 Publish a feed

然而,在第一个应用程序中调用getOpenSession().getPermissions()return一个空列表。因此,我得到了例外 - (原因可能也有所不同,我不确定)。

java.lang.UnsupportedOperationException: Session: an attempt was made to request new permissions for a session that has a pending request.


既然我已经专门要求这些权限,为什么call for getPermissions() return 是一个空数组?我错过了什么吗?

除此之外 other 异常的原因是什么?

事实证明,我在制作 Request 时没有通过正确的 Permissions。我们这样设置 Permissions -

request = new Session.OpenRequest(mActivity);
request.setDefaultAudience(...);
request.setLoginBehavior(...);
request.setPermissions(permission); // <-- This is where we need to specify the permissions.

session.openForPublish(request);

我不知道这是否是正确的解决方案,但它似乎对我有用。