Yii Framework Forum: Facebook Connect - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Facebook Connect Rate Topic: -----

#1 User is offline   nkhanna 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 27-January 13

Posted 06 February 2013 - 06:41 AM

public function actionFblogin()
    {
        $facebook = new Facebook(Yii::app()->params['fb']['config']);
        //$session = $facebook->getSession();
	$user = $facebook->getUser();
        $me = null;

        // Session based API call.
        if ($user)
        {
            $fb_uid = $facebook->getUser();

            if (Yii::app()->user->id)
            {
                $user = User::model()->find('fb_uid=?', array($fb_uid));
                if ($user === NULL)
                {
                    Yii::app()->user->setState('fb_uid', $fb_uid);
                    $this->redirect($this->createAbsoluteUrl('profile/settings', array('fbconnect' => 1)));
                    Yii::app()->end();
                }
                else
                {
                    $this->redirect($this->createAbsoluteUrl('profile/settings', array('fbconnect' => 2)));
                    Yii::app()->end();
                }
            }
            else
            {
            	$user = User::model()->find('fb_uid=?', array($fb_uid));
            	if($user->lastLogin==0)
            		$firstTime=1;
                $_identity = new FbUserIdentity($fb_uid);
                $_identity->authenticate();

                if ($_identity->errorCode === FbUserIdentity::ERROR_NONE)
                {
                    $duration = 3600 * 24 * 30;   // $this->rememberMe ? 3600*24*30 : 0; // 30 days
                    Yii::app()->user->login($_identity, $duration);
                    if($firstTime==1)
                    	$this->redirect($this->createAbsoluteUrl('site/demo', array('name' => $user->firstName)));
                    else
                    	$this->redirect(Yii::app()->user->returnUrl);
                    return true;
                }
                else
                    $this->redirect($this->createAbsoluteUrl('site/fbregister'));
            }
        }
        else
        {
            $this->redirect($facebook->getLoginUrl(array('req_perms' => Yii::app()->params['fb']['config']['perms'], 'return_url' => $this->createAbsoluteUrl('site/fblogin'))));
        }
    }



hi
i have this actionFblogin in my sitecontroller.php
the problem is when i click the button it takes you to facebook page(and it displays error line) THIS IS THE LINK
and it doesnt redirect to my website ?
can anybody help me???
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users