dongxi8993 2011-09-20 21:52
浏览 37

Facebook连接codeigniter

I’m trying to implement facebook connect on my site but I have a very strange problem…

I’ve created a new library for all the tasks relating to authorization. Here is the FB login method:

function fb_login() {

        $config = array(
                'appId' => MY_ID,
                'secret' => 'MY_SECRET',
                'cookie' => true
        );
        $this->ci->load->library('facebook', $config);

        $uid = $this->ci->facebook->getUser();

        if ( $uid )
        {            
            Here I am creating the session...
        }

        return $uid;
} 

The problem is that the getUser() method always returns 0 after the user grants permissions and goes back to my site. If I redirect to facebook login url again (which will of course directly redirects back to my site as the app is already authorized) than is returns the correct value.

Any ideas why the getUser() method doesn’t work for the first time?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 为什么我写出来的绘图程序是这样的,有没有lao哥改一下
    • ¥15 js,页面2返回页面1时定位进入的设备
    • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
    • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
    • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
    • ¥15 绘制多分类任务的roc曲线时只画出了一类的roc,其它的auc显示为nan
    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
    • ¥15 错误 LNK2001 无法解析的外部符号