如何在facebook sdk 3.0 for android中创建具有扩展权限的facebook会话?
答案 0 :(得分:3)
你必须先登录用户。那么当你需要扩展权限时,请执行以下操作:(我已将其用于发布权限)
private static final List<String> PERMISSIONS = Arrays.asList("publish_actions");
private static final int REAUTH_ACTIVITY_CODE = 100;
// Check for publish permissions
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
Session.ReauthorizeRequest reauthRequest = new Session
.ReauthorizeRequest(this, PERMISSIONS)
.setRequestCode(REAUTH_ACTIVITY_CODE);
session.reauthorizeForPublish(reauthRequest);
return;
}
isSubsetOf()
:
private boolean isSubsetOf(Collection<String> subset, Collection<String> superset) {
for (String string : subset) {
if (!superset.contains(string)) {
return false;
}
}
return true;
}
答案 1 :(得分:1)
如果您使用SDK(版本3.0)提供的facebook LoginButton,它将为您处理大部分会话管理,您可以轻松地请求这样的权限:
authButton.setReadPermissions(Arrays.asList("user_location",
"user_birthday", "user_likes"));
请参阅the docs以获取完整的教程。
答案 2 :(得分:0)