Facebook Config
<? if ( ! defined('BASEPATH')) exit('No direct script access allowed'); <?php $config['appId'] = APP_ID; $config['secret'] = APP_SECRET; ?> Controller Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Facebooklogin extends CI_Controller { public function Main() { 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); } function index() { // Try to get the user's id on Facebook $userId = $this->facebook->getUser(); // If user is not yet authenticated, the id will be zero if($userId == 0) { // Generate a login url $data['url'] = $this->facebook->getLoginUrl(array('scope'=>'email')); $this->load->view('signin', $data); } else { // Get user's data and print it $user = $this->facebook->api('/me'); print_r($user); } } } ?> View File
<a href="<?php echo $url;?>"> <button class="btn btn-mini btn-facebook"> <i class="icon-facebook"></i> | Connect with Facebook </button> </a> I have integrated this login api code. when am trying to login, the url does not redirect to the facebook login page. I dont know how to redirect the url.Also i have added configuration file.