Yii Facebook connect

Hello mates, I newbie to Yii… I just started to learn Yii framework.

As part of practice, i implement facebook connect with Yii user management. It successfully implement, but the facebook id and other facebook data like session id and all that is in my url… and another problem is even if i login with facebook successfully, i can’t logined in my sample website…

How can i logged through facebook to my website?? Plz i need help…

Thanks in advance… :) :) :)

check this post for now My link

there are lots of post available here related to this issue.even you can also find content here.i have also implemented a facebook connect a year ago…:)

now i dont have sufficient time to explain about it but i am sure after reading above given link you will get good idea.:)

hey thanks for helping me… I trying some methods from ur link… there are some problems occuring… but will find way… anyway… thanks for help!! :D :)

PLzzz help me m new to yii and want to integrate facebook sign in i have downloaded extension from yiiframework.com named:facebook_connect but i dnt know how to do it working???you cn reply me @hardikmist@gmail.com

PLzzz help me m new to yii and want to integrate facebook sign in i have downloaded extension from yiiframework.com named:facebook_connect but i dnt know how to do it working???you cn reply me @hardikmist@gmail.com

@Hardik Mistry

use this component.place this file in protected/components folder with Facebook.php name




<?php


class Facebook extends CApplicationComponent

{

	public $signedRequest;

	public $permissions;


	public $appId;

	public $appSecret;

	public $tabUrl;

	

	protected $curl;

	protected $me;


	/**

	 * Initializes this application component.

	 * This method is required by the IApplicationComponent interface.

	 */

	public function init()

	{

		parent::init();

		

		// Get the signed request

		if(isset($_REQUEST['signed_request']))

			$this->signedRequest = $this->parseSignedRequest($_REQUEST['signed_request']);


		// Initialize the cURL session

		$this->curl = curl_init();

		curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1);

	}


	/**

	 * Session storage for the most utilised function

	 */

	public function getMe($params = array())

	{

		if(!$this->me)

			$this->me = $this->getCurl('me', $params);


		return $this->me;

	}


	/**

	 * Wrapper cURL function

	 */

	public function getCurl($query, $params = array(), $jsonDecode = true) {

		// Get the access token

		$accessToken = '';

		if(!isset($params['access_token']))

		{

			preg_match('/accessToken=[^&]+/', Yii::app()->user->model->session, $matches);

			$accessToken = str_replace('accessToken', 'access_token', $matches[0]);

		}


		// Form the query

		$paramString = '';

		foreach($params as $key => $val)

			$paramString .= $key.'='.rawurlencode($val).'&';


		$request = 'https://graph.facebook.com/'.$query.'?'.$paramString.$accessToken;


		// Execute the cURL session

		curl_setopt($this->curl, CURLOPT_URL, $request);

		$contents = curl_exec($this->curl);


		// Parse the response

		switch(curl_getinfo($this->curl, CURLINFO_HTTP_CODE)) {

			case 400: // Error

				return false;


			case 200: // Success

			default:

				return $jsonDecode ? json_decode($contents) : $contents;

		}

	}


	/**

	 * See http://developers.facebook.com/docs/authentication/signed_request/

	 */

	public function parseSignedRequest($signedRequest) {

		list($encodedSig, $payload) = explode('.', $signedRequest, 2);


		// Decode the data

		$sig = $this->base64UrlDecode($encodedSig);

		$data = json_decode($this->base64UrlDecode($payload), true);


		if(strtoupper($data['algorithm']) !== 'HMAC-SHA256')

		{

			error_log('Unknown algorithm. Expected HMAC-SHA256');

			return null;

		}


		// Check sig

		$expectedSig = hash_hmac('sha256', $payload, $this->appSecret, $raw = true);

		if($sig !== $expectedSig)

		{

			error_log('Bad Signed JSON signature!');

			return null;

		}


		return $data;

	}


	/**

	 * See http://developers.facebook.com/docs/authentication/signed_request/

	 */

	protected function base64UrlDecode($input)

	{

		return base64_decode(strtr($input, '-_', '+/'));

	}

	

	/**

	 * Clean-up

	 */

	public function __destruct() {

		curl_close($this->curl);

	}

}






Add some thing like this In your config/main.php components array like this:


  

                        ........

                        ........


                       'facebook'=>array(

			'class'=>'Facebook',

			'permissions'=>'',

			'appId'=>'xxxxxxxxxxxxxxx',

			'appSecret'=>'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',

			'tabUrl'=>'http://www.facebook.com/appname/app_xxxxxxxxxxxxxxx',

		),

                        ........

                        ........

–hope this helps