我花了一段時間對此進行分類,以便用戶可以點擊按鈕在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