我花了一段时间对此进行分类,以便用户可以点击按钮在Facebook上分享我的产品。我不希望他们被提示登录,直到他们真的想分享,所以我真的只想要发布权限。以下内容将初始登录/读取权限请求与发布权限请求进行堆叠。这将双重提示用户,首先阅读,然后发布,但现在需要无论解决方案如何:
Session session = Session.getActiveSession();
if (session == null) {
session = new Session.Builder(this).setApplicationId("<APP ID HERE>").build();
Session.setActiveSession(session);
session.addCallback(new StatusCallback() {
public void call(Session session, SessionState state, Exception exception) {
if (state == SessionState.OPENED) {
Session.OpenRequest openRequest = new Session.OpenRequest(FacebookActivity.this);
openRequest.setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK);
session.requestNewPublishPermissions(
new Session.NewPermissionsRequest(FacebookActivity.this, PERMISSIONS));
}
else if (state == SessionState.OPENED_TOKEN_UPDATED) {
publishSomething();
}
else if (state == SessionState.CLOSED_LOGIN_FAILED) {
session.closeAndClearTokenInformation();
// Possibly finish the activity
}
else if (state == SessionState.CLOSED) {
session.close();
// Possibly finish the activity
}
}});
}
if (!session.isOpened()) {
Session.OpenRequest openRequest = new Session.OpenRequest(this);
openRequest.setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK);
session.openForRead(openRequest);
}
else
publishSomething();
嗯,很糟糕的FB sdk设计。 – rahulg 2013-04-09 06:07:43
我有同样的问题,我需要做的是让我的Facebook应用程序共享用户墙上的数据,每次我打开发布会话它不会从已安装的应用程序读取用户令牌,并要求我重新输入我的凭证,所以你发现任何可以帮助我的东西 – 2013-09-18 16:51:11