【问题标题】:Codeigniter not handling question mark in Instagram auth redirectCodeigniter 未处理 Instagram 身份验证重定向中的问号
【发布时间】:2019-01-07 01:15:56
【问题描述】:

在我的网站上,我允许用户链接他们的社交媒体帐户,但我让用户先通过社交媒体 API 进行身份验证,然后再添加他们的用户名。

我在我的公共站点(不是本地主机)上以沙盒模式使用 Instagram 身份验证 API,发送身份验证请求不是问题,但来自 Instagram 的重定向代码包含一个问号,我无法正确解析 URI 段,因为这样,问号后的 URI 段中没有显示任何内容。以下是我的设置。

Instagram 的 URL 是 https://www.instagram.com/oauth/authorize/?client_id=7e9b6fabc5bb49e28d24e32a3232380b&redirect_uri=https://www.mywebsite.com/ig/complete&response_type=code

重定向网址是https://www.mywebsite.com/ig/complete?code=def1efc5f494483a9286b2136e644999

我的路线如下:

$route['ig/complete?(.+)'] = "callback/ig_handle_response/$1";

我的配置允许的字符如下:

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-+?';

当我 print_r 段数组时,输出是 Array( [1] => ig [2] => complete ),URI 段不包含从 Instagram 返回的代码,看起来像问号后的任何内容都会被忽略。

【问题讨论】:

    标签: php api .htaccess instagram codeigniter-3


    【解决方案1】:

    我通过从 URL 中获取 query_string 自己解决了这个问题。

    $code = $this->input->server('QUERY_STRING', TRUE);
    

    $code 的结果是“code=83339246a9c74501b9ffafe65aa222ff”

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-29
      • 1970-01-01
      • 1970-01-01
      • 2012-12-07
      • 2019-11-16
      • 1970-01-01
      相关资源
      最近更新 更多