Facebook API的require_login使用CodeIgniter [英] Facebook API's require_login to work with CodeIgniter

查看:217
本文介绍了Facebook API的require_login使用CodeIgniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,如果我使用facebook的require_login,它似乎进入无限循环附加到url。所有的控制器继承自一个FB_Controller,在建设时:

Currently if I use facebook's require_login, it appears to go into an infinite loop of appending to the url. All of my controllers inherit from a FB_Controller that upon construction does:

$this->facebook = new Facebook($this->API_KEY, $secret);
$this->uid = $this->facebook->require_login(); //Causes infinite loop!

我必须在Facebook上显式地设置canvas回调URL为 http://decider.dfgh.org/ask/index/ (其中问我是我想要的默认控制器)或者我得到一个404错误。

I had to explicitly set the canvas callback URL on Facebook to http://decider.dfgh.org/ask/index/ (where ask is my desired default controller) or else I get a 404 error. Also I'm using the iframe rendering method.

在CodeIgniter我有典型的mod_rewrite摆脱index.php,$ config ['uri_protocol'] =REQUEST_URI ,$ config ['enable_query_strings'] = TRUE。后两种配置,我必须设置,以获得简单的链接工作(点击链接,如 http:// decider .dfgh.org / decisions / 将无法工作,它只会导航到当前页面)。

On CodeIgniter I have the typical mod_rewrite to get rid of index.php, $config['uri_protocol'] = "REQUEST_URI", $config['enable_query_strings'] = TRUE. The latter two configurations I had to set to get simple linking to work (clicking on a link like http://decider.dfgh.org/decide/ would not work, it would just navigate to the current page).

推荐答案

我只是将uri_protocol设置为request_url或path_info,具体取决于referrer标头。所以在config.php我有:

I just set the uri_protocol to either request_url or path_info depending on the referrer header. So in config.php I have:

$config['uri_protocol'] = 
    (isset($_SERVER['HTTP_REFERER']) && 
     strpos($_SERVER['HTTP_REFERER'], 'apps.facebook.com') !== false) ? 
         "PATH_INFO" : "REQUEST_URI";

不是最好的我承认,但它工作。

Not the prettiest I admit but it works.

这篇关于Facebook API的require_login使用CodeIgniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆