检查权限和重定向给出 err_too_many_redirects?

发布于 2024-12-25 04:42:17 字数 728 浏览 0 评论 0原文

我正在使用一些额外的代码调整我的应用程序,例如检查用户是否允许我们需要的权限(也许他在第一次访问后更改了它)。

$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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一场信仰旅途 2025-01-01 04:42:17

为什么不仅在用户执行需要该权限的操作时才提示用户允许扩展权限(或任何权限)?
这是SO问题的链接详细说明如何使用 Facebook JS SDK 请求权限。

如果您的用户删除了某个权限,可能是因为他/她不知道为什么您的应用程序需要该权限。通过仅在用户执行该操作时请求权限,并且可能包括对请求此权限的原因的简短说明,用户可能会倾向于在争论中重新允许您的应用程序获得权限。

编辑
对于重定向,我通常使用 JS 重定向。像这样 :

$url = $facebook->getLoginUrl(array(
      'req_perms' => implode(",",$requiredPermissions), 
      'fbconnect' =>  1,
      'redirect_uri' =>'YOUR_URL'
    ));
echo "<script language=javascript>";
echo "top.location.href = '".$url."';";
echo "</script>";

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 :

$url = $facebook->getLoginUrl(array(
      'req_perms' => implode(",",$requiredPermissions), 
      'fbconnect' =>  1,
      'redirect_uri' =>'YOUR_URL'
    ));
echo "<script language=javascript>";
echo "top.location.href = '".$url."';";
echo "</script>";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文