在codeigniter 3.0.6中进行Facebook集成的问题

时间:2016-06-16 11:38:58

标签: php facebook .htaccess codeigniter

我将Facebook登录集成到Codeigniter 3.0.6。实际上它在localhost中正常工作。当我将相同的代码上传到服务器时,它不会显示任何Facebook个人资料详细信息。我无法在此代码中发现任何问题。

我的控制器:

 public function index(){
 include_once APPPATH."libraries/facebook-api/fb.php";


    $appId = 'my app id';
    $appSecret = 'my scrt code';
    $redirectUrl = 'redirection url';
    $fbPermissions = 'email';


    $facebook = new Facebook(array(
      'appId'  => $appId,
      'secret' => $appSecret

    ));
    $fbuser = $facebook->getUser();

    if ($fbuser) {
        $userProfile = $facebook->api('/me?fields=id,first_name,last_name,email,gender,locale,picture');

        $userData['oauth_provider'] = 'facebook';
        $userData['oauth_uid'] = $userProfile['id'];
        $userData['first_name'] = $userProfile['first_name'];
        $userData['last_name'] = $userProfile['last_name'];
        $userData['email'] = $userProfile['email'];
        $userData['gender'] = $userProfile['gender'];
        $userData['locale'] = $userProfile['locale'];
        $userData['profile_url'] = 'https://www.facebook.com/'.$userProfile['id'];
        $userData['picture_url'] = $userProfile['picture']['data']['url'];

        $userID = $this->user->checkUser($userData);
        if(!empty($userID)){
            $data['userData'] = $userData;
            $this->session->set_userdata('userData',$userData);
        } else {
           $data['userData'] = array();
        }
    } else {
        $fbuser = '';
        $data['authUrl'] = $facebook->getLoginUrl(array('redirect_uri'=>$redirectUrl,'scope'=>$fbPermissions));
    }
    $this->load->view('uservw/index',$data);
}

在配置文件中启用查询sting。

我不知道我的.htaccess文件有什么问题。

这是我的htaccess文件。

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]

0 个答案:

没有答案