Monday, 9 September 2013

Login with facebook error, codeigniter invalid url

Login with facebook error, codeigniter invalid url

I am working on a project. I want the user login with facebook. But after
the facebook authentication, I get this error:
Given URL is not allowed by the Application configuration.: One or more of
the given URLs is not allowed by the App's settings. It must match the
Website URL or Canvas URL, or the domain must be a subdomain of one of the
App's domains.
I searched on Google for a long time and everytime I get this answer that
there may be a problem in my facebook application domain name.
I changed my fb application again and again but everytime I get the same
error.
Some settings of my facebook application are:
App Domains: superhitdomains.com
Site URL: http://superhitdomains.com
My view page is :
Login with facebook
and my controller is:
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Social extends CI_Controller {
public function __construct(){
parent::__construct();
parse_str( $_SERVER['QUERY_STRING'], $_REQUEST );
$CI = & get_instance();
$CI->config->load("facebook",TRUE);
$config = $CI->config->item('facebook');
$this->load->library('Facebook', $config);
}
public function fb_request(){
$userId = $this->facebook->getUser();
if($userId == 0){
$data = array(
'redirect_uri'=> base_url().'social/handle_user_fb_login',
'scope'=>'email'
);
redirect($this->facebook->getLoginUrl($data));
//print_r($data); exit;
}
else {
// Get user's data and print it
$user = $this->facebook->api('/me');
print_r($user);
}
}
public function handle_user_fb_login(){
$userId = $this->facebook->getUser();
if($userId !=0){
$user = $this->facebook->api('/me');
print_r($user);
}
else {
echo 'could not connected with facebook';
}
}
}
Can anyone help me what is wrong with my code?
Thanks

No comments:

Post a Comment