检查权限和重定向给出 err_too_many_redirects?
我正在使用一些额外的代码调整我的应用程序,例如检查用户是否允许我们需要的权限(也许他在第一次访问后更改了它)。
$permissions_needed = array('publish_stream,read_stream');
foreach($permissions_needed as $perm) {
if( !isset($permissions_list['data'][0][$perm]) || $permissions_list['data'][0][$perm] != 1 ) {
$login_url_params = array(
'scope' => 'publish_stream,read_stream',
'fbconnect' => 1,
'next' => 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']
//redirect_uri => 'https://www.mydomain.com/fb_app/'
);
$login_url = $facebook->getLoginUrl($login_url_params);
header("Location: {$login_url}");
exit();
}
我该如何解决这个问题?何时使用 next 与 redirect_uri 作为参数?
I am tweaking my application with some extra code, like checking if the permissions we need have been allowed by the user (maybe he has changed it after his first visit).
$permissions_needed = array('publish_stream,read_stream');
foreach($permissions_needed as $perm) {
if( !isset($permissions_list['data'][0][$perm]) || $permissions_list['data'][0][$perm] != 1 ) {
$login_url_params = array(
'scope' => 'publish_stream,read_stream',
'fbconnect' => 1,
'next' => 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']
//redirect_uri => 'https://www.mydomain.com/fb_app/'
);
$login_url = $facebook->getLoginUrl($login_url_params);
header("Location: {$login_url}");
exit();
}
How do i fix this? And when to use next vs redirect_uri as params?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不仅在用户执行需要该权限的操作时才提示用户允许扩展权限(或任何权限)?
这是SO问题的链接详细说明如何使用 Facebook JS SDK 请求权限。
如果您的用户删除了某个权限,可能是因为他/她不知道为什么您的应用程序需要该权限。通过仅在用户执行该操作时请求权限,并且可能包括对请求此权限的原因的简短说明,用户可能会倾向于在争论中重新允许您的应用程序获得权限。
编辑
对于重定向,我通常使用 JS 重定向。像这样 :
Why dont you only prompt your users to allow extended permissions (or any permission) only when they are performing the action that requires that permission?
Here is a link to a SO Question detailing how to request permissions with the Facebook JS SDK.
If your use removed a certain permission it might have been because he/she did not know why your application needs that permission. By requesting for the permission only when the user performs that action, and maybe including a short explication on why you are requesting this permission, the users might be inclined to re-allow your application the permission in debate.
EDIT
For re-directions I usually use a JS redirect. Like this :