Ejemplo n.º 1
0
 /**
  * login with facebook sdk
  *
  * @param String $appId, $appSecret, $redirectUrl
  *
  * @return boolean
  */
 public function login($appId, $appSecret, $redirectUrl)
 {
     $redirectUrl = 'http://' . $_SERVER['HTTP_HOST'] . $redirectUrl;
     $request = new Request();
     FacebookSession::setDefaultApplication($appId, $appSecret);
     $helper = new FacebookRedirectLoginHelper($redirectUrl);
     try {
         $session = $helper->getSessionFromRedirect();
     } catch (FacebookRequestException $ex) {
         // When Facebook returns an error
     } catch (\Exception $ex) {
         // When validation fails or other local issues
     }
     $this->loginurl = $helper->getLoginUrl();
     if ($session) {
         $FacebookRequest = new FacebookRequest($session, 'GET', '/me');
         $response = $FacebookRequest->execute();
         $graph = $response->getGraphObject(GraphUser::classname());
         $name = $graph->getName();
         $accessToken = $session->getAccessToken();
         $request->setSession('facebook', (string) $accessToken);
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 2
0
 public function view()
 {
     $request = new Request();
     $post = "";
     $get = "";
     if ($request->post['post']) {
         $post = $request->post['post'];
     }
     if ($request->get['get']) {
         $get = $request->get['get'];
     }
     //set cookie
     $request->setCookie('test', 'testValue', 300);
     $cookie = $request->cookie['test'];
     //destroy cookie
     $request->destroyCookie('test');
     //check if an file was sent
     if (isset($request->files['file'])) {
         $fileset = 'true';
     } else {
         $fileset = 'false';
     }
     $server = $request->server;
     //set session
     $request->setSession('test', 'testSessionValue');
     $session = $request->session['test'];
     return $this->render("usability:http.html", array('post' => $post, 'get' => $get, 'cookie' => $cookie, 'fileset' => $fileset, 'server' => $server, 'session' => $session));
 }
Ejemplo n.º 3
0
 /**
  *
  * The logoutMethod logs out by killing Cookie and destroy session
  * 
  * @param dynamic $cookie
  * 
  * @return void
  */
 public function logout($cookie = '')
 {
     $request = new Request();
     session_destroy();
     if (is_array($cookie)) {
         foreach ($cookie as $cookieName) {
             $request->destroyCookie($cookieName);
         }
     } else {
         if (!empty($cookie)) {
             $request->destroyCookie($cookie);
         }
     }
 }