我正在關注Facebook的Facebook的Android共享教程(https://developers.facebook.com/docs/android/share)。該應用程序運行良好,我可以登錄Facebook點擊演示分享按鈕。所以這是我的應用程序的過程:Facebook的SDK 3.8:權限publish_actions不返回
- 登錄與Facebook
- Facebook的會話對象更新,並且以下權限保存在session對象中:
user_likes, user_friends, user_status, basic_info
- 現在,我想分享的東西。因此,用戶點擊分享按鈕,並額外許可的請求被稱爲
publish_actions
由
下面的代碼執行這個請求:
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
。
更多評論:我讀過一些問題,說應該出現一個額外的彈出窗口,要求用戶授予權限。然而,這不會發生在我的情況。也許這是問題?如果是這樣,我需要做些什麼來獲得彈出窗口?
更新:我還額外嘗試從github下面的要點:https://gist.github.com/vishalpawale/5556996 此示例代碼由於完全相同的原因失敗。它沒有獲得任何publish_action權限。似乎是Facebook SDK中的一個實際錯誤?
我不確定,但我現在我正試圖解決這個問題。顯然Facebook已經撤消了通過API發佈帖子的能力。你有沒有找到解決方案? – Wordica
我跟隨developers.facebook.com/docs/android/share示例發佈到用戶牆。如果我使用應用程序開發人員電子郵件登錄Facebook,它工作正常對於非開發人員,我沒有獲得許可......這是否也會發生在你身上? –
同樣的問題,未授予publish_action權限。 –