daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Jan 21st, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class FacebookController extends Controller {
  2.     private function getFacebookAccess(){
  3.         $facebook = new \Facebook(array(
  4.                 'appId' => self::APP_ID,
  5.                 'secret' => self::SECRET
  6.             ));
  7.  
  8.         //var_dump($facebook);
  9.         $fcbkUser = $facebook->getUser();
  10.  
  11.         //var_dump($fcbkUser);
  12.         if ( ! $fcbkUser ) {
  13.             $error_msg = "We have problems trying to connect with Facebook, try it later on!";
  14.             //echo $error_msg;
  15.             $this->get('session')->getFlashBag()->add('error', $error_msg);
  16.             return null;
  17.         }else{
  18.             return $facebook;
  19.         }
  20.  
  21.     }
  22.  
  23.     public function connectAction($callback)
  24.     {
  25.         $facebook = $this->getFacebookAccess($facebook);
  26.         if(empty($facebook){
  27.             $return_url = $this->getRequest()->headers->get('referer');
  28.                 return $this->redirect($return_url);
  29.             }
  30.             //var_dump($facebook);
  31.         // CHANGED: Verificar que es un string sencillo que haga matching con las rutas
  32.         if (!empty($callback)) {
  33.             $callback_url_facebook = $this->get('router')->generate($callback, array(), true);
  34.         }
  35.             $facebook_url = $facebook->getLoginUrl ( array (
  36.                 'redirect_uri' => $callback_url_facebook,
  37.                 'scope' => "email,publish_stream"
  38.             ) );
  39.             //var_dump($facebook_url);
  40.         return $this->redirect($facebook_url);
  41.     }
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top