我试图请求获得许可" publish_actions"在Facebook帐户链接后。但每当我发出请求时,它都不会添加到Session.getPermissions()中的权限列表。
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
buttonPost.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Session session = Session.getActiveSession();
if (session != null) {
// Check for publish permissions
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
Session.NewPermissionsRequest newPermissionsRequest = new Session
.NewPermissionsRequest(this, PERMISSIONS);
pendingPublishReauthorization = true;
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}
// publish story code
publishStory();
}
});
// Facebook Session Call Back
private class SessionStatusCallback implements Session.StatusCallback {
@Override
public void call(Session session, SessionState state,
Exception exception) {
if (session.isOpened()) {
if (pendingPublishReauthorization && state.equals(SessionState.OPENED_TOKEN_UPDATED)) {
pendingPublishReauthorization = false;
publishStory();
}
}
}
}
private Session.StatusCallback statusCallback = new SessionStatusCallback();
public static final List<String> PERMISSIONS = Arrays.asList("publish_actions");
private boolean pendingPublishReauthorization = false;
出现在logCat
中01-07 14:51:39.882: D/FacbookPostAdmin(6685): Session State: OPENED_TOKEN_UPDATED
01-07 14:51:39.882: D/FacbookPostAdmin(6685): Session Permissions: [public_profile]
也在Graph API Explorer中