gpt4 book ai didi

java - 如何使用扩展权限创建 Facebook session

转载 作者:搜寻专家 更新时间:2023-11-01 08:05:18 25 4
gpt4 key购买 nike

如何在 facebook sdk 3.0 for android 中创建具有扩展权限的 facebook session ?

最佳答案

您必须先登录用户。然后当您需要扩展权限时,请执行以下操作:(我已将其用于发布权限)

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;
}

关于java - 如何使用扩展权限创建 Facebook session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15133633/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com