facebook - Symfony2 and PHP SDK 4.0 session issue while login -


i trying integrate facebook php-sdk 4 , symfony2

i installed facebook sdk using composer , using basic code facebook developer documentation

generate facebook login url

public function indexaction(request $request) {         //generate         facebooksession::setdefaultapplication('appid', 'secret');         $redirecturl = $this->generateurl('auth_facebookredirect');         $helper = new facebookredirectloginhelper($redirecturl);         $helper->disablesessionstatuscheck();         $loginurl = $helper->getloginurl();         return $this->render('userbundle:fb:index.html.twig', array('loginurl'=>$loginurl));     } 

callback or facebook redirect after login success

public function successaction(request $request) {         facebooksession::setdefaultapplication('appid', 'secret');          $redirecturl = $this->generateurl('auth_facebookredirect');         $helper = new facebookredirectloginhelper();         //$session = $helper->getsessionfromredirect();          try {             $session = $helper->getsessionfromredirect();          } catch (facebookrequestexception $ex) {             echo " when facebook returns error";         } catch (\exception $ex) {                         echo " when validation fails or other local issues";         }         if ($session) {             $me = (new facebookrequest(                     $session, 'get', '/me'                     ))->execute()->getgraphobject(graphuser::classname());             var_dump($me);         }         return $this->render('userbundle:fb:success.html.twig', array());     } 

first got error

facebooksdkexception: session not active, not store state.

i came across this link , says there issue session , used

$helper->disablesessionstatuscheck();

because of login worked, when got redirected facebook callback url / redirect url after fb login got exception

defaultapplication not set

so added facebooksession::setdefaultapplication('appid', 'secret'); @ successaction

still error after login @ section below, can't session here.

try {             $session = $helper->getsessionfromredirect();          } catch (facebookrequestexception $ex) {             echo " when facebook returns error";         } catch (\exception $ex) {                         echo " when validation fails or other local issues";          } 

i error here catch (\exception $ex) {
echo " when validation fails or other local issues"; }

$session = helper->getsessionfromredirect();

what causing error here, facebook login credentials correct.

i unable figure out error.

try doing way.

$helper = new facebookredirectloginhelper(                 $this->generateurl('app_home',[],true),//generates absolute ur;                 $this->container->getparameter('facebook_sdk.app_id'), //api id                 $this->container->getparameter('facebook_sdk.app_secret')//app secret             ); 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -