Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Follow these steps:</p> <pre><code>1.Put the facebook php sdk in library folder 2.create facebook config with app detail 3.Inherit facebook class in fb_connect 4.add these function in controller then it will work like charm. </code></pre> <p>fb_connect.php</p> <pre><code>&lt;?php include(APPPATH.'libraries/facebook/facebook.php'); class Fb_connect extends Facebook{ //declare public variables public $user = NULL; public $user_id = FALSE; public $fb = FALSE; public $fbSession = FALSE; public $appkey = 0; //constructor method. public function __construct() { $CI = &amp; get_instance(); $CI-&gt;config-&gt;load("facebook",TRUE); $config = $CI-&gt;config-&gt;item('facebook'); parent::__construct($config); $this-&gt;user_id = $this-&gt;getUser(); // New code $me = null; if ($this-&gt;user_id) { try { $me = $this-&gt;api('/me'); $this-&gt;user = $me; } catch (FacebookApiException $e) { error_log($e); } } } } // end class </code></pre> <p>Controller function </p> <pre><code>function loginByFacebook(){ $this-&gt;load-&gt;library('fb_connect'); $param = array( 'scope' =&gt;'email,user_location,user_birthday,offline_access', 'redirect_uri' =&gt; base_url() ); redirect($this-&gt;fb_connect-&gt;getLoginUrl($param)); } function facebook() { if (!$this-&gt;fb_connect-&gt;user_id) { } else { $fb_uid = $this-&gt;fb_connect-&gt;user_id; $fb_usr = $this-&gt;fb_connect-&gt;user; $firstname = $fb_usr['first_name']; } } </code></pre> <p>In this way</p> <pre><code>$fb_usr = $this-&gt;fb_connect-&gt;user; $firstname = $fb_usr['first_name']; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload