您好,我收到了来自 facebook 开发者的警告:
您的应用程序同时要求读取和写入权限。只有当用户尝试向 Facebook 分享内容时,您才应该请求写入权限。
我应该怎么做才能解决这个问题?
谢谢你。
您好,我收到了来自 facebook 开发者的警告:
您的应用程序同时要求读取和写入权限。只有当用户尝试向 Facebook 分享内容时,您才应该请求写入权限。
我应该怎么做才能解决这个问题?
谢谢你。
In the rare case your app requires publishing permissions up front (for example, an app that does nothing but publish a user's mood to Facebook).
(1)first request the bare minimum read permissions at initial login. After the user logs in with Facebook,
(2)show the user a screen explaining why your app needs publishing permissions and let the user opt-in to the publishing permission request by clicking a button.
This will provide the user more context and improve your conversion.
Another legitimate case for requesting read and publish permissions back-to-back is for users that log in to your app with email or a non-Facebook login option.
When these users want to publish to Facebook, your app will need to request read permissions to connect their account followed by publishing permissions back-to-back.
In this case, make sure that the only read permissions you request are public profile and friend list.
This provides the best user experience because the user wants to simply publish from your app and is not interested in providing additional read permissions.
It will also improve your conversion.
您需要包含扩展权限才能使用“publish_actions”。
本指南说明了如何设置权限并将帖子发布到墙上。基本上,如前所述,所需的权限包括如下:
private static final List<String> PERMISSIONS = Arrays.asList("publish_actions");
为了发布故事,他们甚至为您提供了必要的代码,该代码也利用了“publish_actions”权限:
private void publishStory() {
Session session = Session.getActiveSession();
if (session != null){
// Check for publish permissions
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session
.NewPermissionsRequest(this, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
} ... }
他们还使用以下代码检查权限:
private boolean isSubsetOf(Collection<String> subset, Collection<String> superset) {
for (String string : subset) {
if (!superset.contains(string)) {
return false;
}
}
return true;
}
这意味着,您只需要使用写入权限,而不是读取权限。
希望这可以帮助。