Codeigniter Facebook SDK Tutorials : create facebook application using codeigniter

Share on TwitterDigg This

Tutorial to create facebook application using codeigniter php framework.



link to download
download from github

Step 1:Set the facebook application key and secret key to facebook.php file in appln/config folder

<?php
$config['facebook_app_id'] = 'your app_id';
$config['facebook_api_secret']='your app secret id';
$config['facebook_default_scope']='email,user_birthday,user_location,photo_upload, 
user_photos,user_photo_video_tags,user_work_history,user_about_me,user_hometown';
$config['facebook_api_url'] = 'https://graph.facebook.com/'; // Just in case it changes.
</php>

Step 2:Load the facebook library file to your function

$this->load->config('facebook');
                $this->_api_url 	= $this->config->item('facebook_api_url');
		$this->_api_key 	= $this->config->item('facebook_app_id');
		$this->_api_secret 	= $this->config->item('facebook_api_secret');
		$this->_default_scope	= $this->config->item('facebook_default_scope');
		$config = array(
					'appId'  => $this->_api_key,
					'secret' => 	$this->_api_secret,
					'fileUpload' => true, // Indicates if the CURL based @ syntax for file uploads is enabled.
				);
		$this->load->library('Facebook', $config);//load facebook library for facebook sdk

after the above two steps we can call the function to get and access the facebook api

To get the facebook user id

function get_user(){//return the facebook user id
		return $this->_user=$this->facebook->getUser();
	}

To get facebook login url

function get_login_url(){//return the facebook login url. like to change the scope of loginUrl(config/facebook.php)
	return  $this->facebook->getLoginUrl(
            array(
                'scope'         => $this->_default_scope
            )
    );
}

To get the facebook logout url

function get_logout_url(){//return the facebook logoutUrl
 
	return  $this->facebook->getLogoutUrl();
}

 

Related

About prabin t p

Connect with me on Google+
This entry was posted in codeigniter, facebook and tagged . Bookmark the permalink.

6 Responses to Codeigniter Facebook SDK Tutorials : create facebook application using codeigniter

  1. Ethan says:

    Hey,

    I couldn’t download the file. Can you repost it?

  2. Frank says:

    der WebInOne Blog gibt es einen Beitrag fcber das Tun einiger Datum Validierung in CodeIgniter 2 Formulare mit dem set_validation -Methode. Ich scherib ein Tutorial hier fcber die

    • Disesp says:

      Hi,Im trying to inmlemept Your tutorial, and as far as first part everything works But i don’t understand one thing in second part (posting to wall) We have variable $this->fbSession in fb_connect.php controller but its defined as FALSE, and nowhere changed so it is still FALSE So the post_to_wall function will always return FALSE Can You point me where i’m wrong or what is missing?Try, and Keep Up Good Work

  3. Constantin Alin says:

    I couldn’t download the file. Can you send it ? (fbdsk.raz 4,7 KO)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">