嗨,我正在使用新的 facebook SDK 3.0 开发 android 应用程序。
我尝试在用户登录后请求“publish_stream”权限。所以,在 onSessionStateChange() 中,我输入了请求“publsh_stream”权限的代码,但它不起作用。
这是我的代码:
private void onSessionStateChange(Session session, SessionState state, Exception exception) {
if (state.isOpened()) {
if (pendingPublishReauthorization && state.equals(SessionState.OPENED_TOKEN_UPDATED)) {
pendingPublishReauthorization = false;
publishFeed(userName);
}
m_pd.show();
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
String username=buildUserInfoDisplay(user);
userName=username;
saveAccount(username, "facebook");
Log.d(com.dress.folio.Constants.FACEBOOK_TAG, "login success");
//publishFeed(userName);
m_pd.dismiss();
h.postDelayed(irun, 1000);
Activity GetActivity=getActivity();
if(GetActivity != null) GetActivity.finish();
}
}
});
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions) ) {
pendingPublishReauthorization = true;
//if(state == SessionState.OPENED_TOKEN_UPDATED) {
Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(this, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
//}
}
} else if (state.isClosed()) {
Log.i(com.dress.folio.Constants.FACEBOOK_TAG, "Logged out..." + exception);
}
}
在行 session.requestNewPublishPermissions(newPermissionsRequest); 处,编译器总是说错误,例如:尝试为具有待处理请求的会话请求新权限。
用户 facebook SSO 在我的应用程序中登录后,如何立即请求 publish_stream。?