Facebook connect extension

This is still in development version , but works fine :)

Try it Facebook Extension

Demo url Facebook demo

Enjoy :)

looks great

thanks for sharing

Very good Igor,

Thanks for sharing. Keep up with the good work.

Thanks Antonio , i will have some little changes but i have to figured out how to change :)

Nice extension Igor… keep the good work going :D

Hi Igor,

I tried this extension, but it didn’t work.

This is what I did:

  1. After I downloaded and extracted the zip file, I moved folder facebook to protected/extensions/. So, now I have facebook folder under proctected/extensions

  2. I added this function to SiteController




 protected $_identity;

 public $_logouturl;

 

 public function actionFblogin(){

        if($this->_identity===null)

        {

            $this->_identity=new FBIdentity($_GET['username'],$_GET['userid']);

            $this->_identity->authenticate();

            $this->_logouturl = $_GET['logout'];

 

 

            $error = 0;

            if($error===FBIdentity::ERROR_NONE){

 

            $duration=3600*24*30; 

            Yii::app()->user->login($this->_identity,$duration);

            $this->redirect(Yii::app()->homeUrl);

 

            }else{

            return false;

            }

        }

}



  1. Next, I added a new class named FBIdentity under protected/components/ with this content:



<?php

class FBIdentity extends CUserIdentity{

 

    private $_id;

    public function authenticate(){

    $this->_id = $this->password;

    return $this->errorCode==self::ERROR_NONE;

    }

    public function getId()

    {

    return $this->_id;

    }

 

}



  1. Then, I put this code in my _form.php view.



<?php  

$this->widget('application.extensions.facebook.FbLogin',

array(

        'devappid'=>'MYFACEBOOKDEVAPI',   //your appilaction id

        'devsecret'=>'MYFACEBOOKDEVSECRET', //your application secret

        'cookie'=>FALSE,   

));

?>



So, when I opened the page from the browser, I got the following error:

Use of undefined constant CURLOPT_CONNECTTIMEOUT - assumed ‘CURLOPT_CONNECTTIMEOUT’

/home/ihot/public_html/adrobust/protected/extensions/facebook/FbLogin.php(27)

Did I miss something? Any idea?

Thanks!

-Laurent

Never mind, I think I figured it out:




public static $CURL_OPTS = array(

    'CURLOPT_CONNECTTIMEOUT' /* PUT BETWEEN SINGLE QUOTES */ => 10,

    'CURLOPT_RETURNTRANSFER' /* PUT BETWEEN SINGLE QUOTES */ => true,

    'CURLOPT_TIMEOUT'  /* PUT BETWEEN SINGLE QUOTES */       => 60,

    'CURLOPT_USERAGENT'  /* PUT BETWEEN SINGLE QUOTES */     => 'facebook-php-2.0',

  );



in which file you put this statement?

I have the same error…!


<?php

class FBIdentity extends CUserIdentity{

 public boolean $allowAutoLogin = TRUE;

    private $_id;

    public function authenticate(){

		die("entering authentication");

    $this->_id = $this->password;

	echo "After";

    return $this->errorCode==self::ERROR_NONE;

    }

    public function getId()

    {

    return $this->_id;

    }

 

}

?>



This is FBIdentity.php (Component)

We are calling this FBIdentity from fblogin action (in my users controller)


public function actionFblogin(){

		

	 if($this->_identity===null)

        {

			echo "coming";

            $this->_identity=new FBIdentity($_GET['username'],$_GET['userid']);

			echo "coming";

            $this->_identity->authenticate();

My doubt may look dumb…,

Step 1: I am logged in to Facebook.

Step 2: I got some dynamic url returned from facebook.

Step 3: "coming" is printing

Code below that first "coming" string isnt working.

Note: I am using fblogin action in my Users controller. (Am I need to extend it to something else or add anything?)

Am I having WRONG FBIdentity.php code?

Because., There are no constructor or anything …

Please help or explain… I have tried almost all available facebook connect plugins for Yii. Finally I found this extension looks clean. Please help.

[color="#006400"]<mod>quote removed</mod>[/color]

[i]

[/i]I got the same error, but can’t figure out how to solve that… plz anyone help me out… :(

Very funny… :) for ur kind information, i already posted new question regarding facebook integration… I think ur too lazy to see new post! B) :(

Touche!

Ashutosh, you have a point there.

It wasn’t really directed at you alone - I see this all the time: people tag along on a post, with only one line: “I have the same problem…”

I just had to get it out of my system.

Hey,No hard feelings…

I just need some help that’s why i posted on forum. I understand your point. :) :D

It is in the same file (facebook.php)

if you do a search for ‘curl’, in vim its’ :/curl/

you’ll see the below:







class Facebook




...





  /**

   * Default options for curl.

   */

  public static $CURL_OPTS = array(

    CURLOPT_CONNECTTIMEOUT => 10,

    CURLOPT_RETURNTRANSFER => true,

    CURLOPT_TIMEOUT        => 60,

    CURLOPT_USERAGENT      => 'facebook-php-2.0',

  );


 

...




change this to:





  /**

   * Default options for curl.

   */

  public static $CURL_OPTS = array(

    'CURLOPT_CONNECTTIMEOUT' => 10,

    'CURLOPT_RETURNTRANSFER' => true,

    'CURLOPT_TIMEOUT'        => 60,

    'CURLOPT_USERAGENT'      => 'facebook-php-2.0',

  );






and you’re good.

cheers

J