I'm integrating Facebook login to Codeigniter 3.0.6 . Actually it's working fine in localhost. when I uploaded the same code to the server, it wont show any facebook profile details. I couldn't find out any issues in this code.
My controller:
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);
}
enabled query sting in config file.
i dont know is there any issue with my .htaccess file.
here is my htaccess file.
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]