当前位置: 首页>>代码示例>>PHP>>正文


PHP FacebookRedirectLoginHelper::getReRequestUrl方法代码示例

本文整理汇总了PHP中Facebook\FacebookRedirectLoginHelper::getReRequestUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP FacebookRedirectLoginHelper::getReRequestUrl方法的具体用法?PHP FacebookRedirectLoginHelper::getReRequestUrl怎么用?PHP FacebookRedirectLoginHelper::getReRequestUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Facebook\FacebookRedirectLoginHelper的用法示例。


在下文中一共展示了FacebookRedirectLoginHelper::getReRequestUrl方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: connect

 /**
  * @param $redirect_url
  * @return string|Facebook\GraphUser Login URL or GraphUser
  */
 function connect($redirect_url)
 {
     FacebookSession::setDefaultApplication($this->appId, $this->appSecret);
     $helper = new FacebookRedirectLoginHelper($redirect_url);
     if (isset($_SESSION) && isset($_SESSION['fb_token'])) {
         $session = new FacebookSession($_SESSION['fb_token']);
     } else {
         $session = $helper->getSessionFromRedirect();
     }
     if ($session) {
         try {
             $_SESSION['fb_token'] = $session->getToken();
             $request = new FacebookRequest($session, 'GET', '/me');
             $profile = $request->execute()->getGraphObject('Facebook\\GraphUser');
             if ($profile->getEmail() === null) {
                 throw new \Exception('L\'email n\'est pas disponible');
             }
             return $profile;
         } catch (\Exception $e) {
             unset($_SESSION['fb_token']);
             return $helper->getReRequestUrl(['email']);
         }
     } else {
         return $helper->getLoginUrl(['email']);
     }
 }
开发者ID:rizof,项目名称:Laravel-conexion,代码行数:30,代码来源:ConnexionFacebook.php

示例2: testReRequestUrlContainsState

 public function testReRequestUrlContainsState()
 {
     $helper = new FacebookRedirectLoginHelper(self::REDIRECT_URL, FacebookTestCredentials::$appId, FacebookTestCredentials::$appSecret);
     $helper->disableSessionStatusCheck();
     $reRequestUrl = $helper->getReRequestUrl();
     $state = $_SESSION['FBRLH_state'];
     $this->assertContains('state=' . urlencode($state), $reRequestUrl);
 }
开发者ID:doobas,项目名称:kazinopaslaptys,代码行数:8,代码来源:FacebookRedirectLoginHelperTest.php

示例3: handle_rerequest_permission

function handle_rerequest_permission()
{
    render_boilerplate();
    // Simplification: always assume we are not logged in!
    $helper = new FacebookRedirectLoginHelper(MY_URL . 'fb_callback/');
    // We do want to publish to the user's wall!
    $scope = array('publish_actions');
    $fb_login_url = $helper->getReRequestUrl($scope);
    Flight::render('rerequest_permission', array('fburl' => $fb_login_url));
}
开发者ID:monat78,项目名称:fbwlan,代码行数:10,代码来源:fb_handlers.php

示例4: connect

 /**
  * @return string|Facebook\GraphUser Login URL or GraphUser
  */
 public function connect()
 {
     $helper = new FacebookRedirectLoginHelper($this->redirectUrl);
     if (isset($_SESSION) && isset($_SESSION['fb_token'])) {
         $this->setSession(new FacebookSession($_SESSION['fb_token']));
     } else {
         $this->setSession($helper->getSessionFromRedirect());
     }
     if ($this->getSession()) {
         try {
             $_SESSION['fb_token'] = $this->getSession()->getToken();
             $profile = $this->getUser();
             if ($profile->getEmail() === null) {
                 throw new \Exception("L'email n'est pas disponible");
             }
             return $profile;
         } catch (\Exception $e) {
             unset($_SESSION['fb_token']);
             return $helper->getReRequestUrl($this->scope);
         }
     } else {
         return $helper->getLoginUrl($this->scope);
     }
 }
开发者ID:christopherfouquier,项目名称:facebook,代码行数:27,代码来源:Facebook.php

示例5: reRequest

 public function reRequest()
 {
     $helper = new FacebookRedirectLoginHelper("http://local.dev/projets/zoneroot/fbconnect/test.php");
     echo '<a href="' . $helper->getReRequestUrl(['email']) . '">rerequest</a>';
 }
开发者ID:zoneroot,项目名称:fbconnect,代码行数:5,代码来源:fbconnect.php

示例6: callbackLoginFacebookAction

 /**
  * Callback from Facebook.
  *
  * When user goes through the Facebook oAuth 2.0 process
  * of login in, after he has logged into Facebook, he/she is redirected to this
  * this action. Here he/she is authenticated to the system and if that works the user
  * is logged in. If this does not work, the user is asked it this is his first time logging
  * in via Facebook and if he/she is sure that he/she has an account.
  *
  * @return \Zend\Http\Response|ViewModel
  * @throws \Exception
  */
 public function callbackLoginFacebookAction()
 {
     //GET SERVER
     //	 this check has to be done for instances where this
     //	is not run as an web-application
     $server = isset($_SERVER['HTTP_HOST']) ? "http://" . $_SERVER['HTTP_HOST'] : 'http://0.0.0.0';
     //FACEBOOK CONFIG
     //	get config and use it to cnfigure facebook session
     //	and login functionality
     $config = $this->getServiceLocator()->get('Config');
     FacebookSession::setDefaultApplication($config['facebook']['appId'], $config['facebook']['secret']);
     //TODO should this be in a global space
     //ERROR
     $error = $this->params()->fromQuery('error');
     if ($error == 'access_denied') {
         return new ViewModel(['error' => 'access_denied']);
     }
     //KEY
     //	check if there is a query parameter called $key along
     //	for the ride. If so; then the user is trying to connect old account
     //	to Facebook.
     $key = $this->params()->fromQuery('key');
     //TODO validate this key
     //CONNECTING OLD ACCOUNT
     //	if $key is present, then the callback from Facebook will contain it and
     //	we have to reflect it in the callback validation
     $helper = new FacebookRedirectLoginHelper($key ? $server . AuthController::LOGIN_CALLBACK_FACEBOOK . '?key=' . $key : $server . AuthController::LOGIN_CALLBACK_FACEBOOK);
     //LOGIN
     //	try to log in user
     try {
         //FACEBOOK OBJECT
         //	get user object/properties from facebook graph
         $session = $helper->getSessionFromRedirect();
         if (!$session) {
             throw new \Exception("Facebook session was NULL, key[{$key}], url[{$helper->getReRequestUrl()}]");
         }
         $me = (new FacebookRequest($session, 'GET', '/me'))->execute()->getGraphObject(GraphUser::className())->asArray();
         //CONNECT OLD ACCOUNT CUT-IN
         //	if $key is set, then the user is trying to connect old account to his
         //	Facebook. What we do here is to find the user based on the hash that we got
         //	back from facebook, then we inject the Facebook Auth-ID into his table just
         //	in time so that '$auth = new AuthenticationService();' line of code will pick
         //	it up and authenticate the user. This is just a little detour to quickly connect
         //	the user to a facebook account just before we authenticate him.
         if ($key) {
             $sm = $this->getServiceLocator();
             $userService = $sm->get('Stjornvisi\\Service\\User');
             /** @var $userService \Stjornvisi\Service\User */
             if (($user = $userService->getByHash($key)) != null) {
                 $userService->setOauth($user->id, $me['id'], 'facebook', $me['gender']);
                 //USER NOT FOUND
                 //	can't find the user based on hash
             } else {
                 return new ViewModel(['error' => 'user_undefined']);
             }
         }
         //AUTHENTICATE
         //	try to authenticate user against user database
         $auth = new AuthenticationService();
         $sm = $this->getServiceLocator();
         $authAdapter = $sm->get('Stjornvisi\\Auth\\Facebook');
         $authAdapter->setKey($me['id']);
         $result = $auth->authenticate($authAdapter);
         //VALID
         //	user has logged in before via Facebook
         if ($result->isValid()) {
             $sessionManager = new SessionManager();
             $sessionManager->rememberMe(21600000);
             //250 days
             return $this->redirect()->toRoute('home');
             //INVALID
             //	user hasn't logged in with facebook before. We have
             //	to initialize the connection process.
         } else {
             return new ViewModel(['error' => 'user_disconnected']);
         }
         //CAN'T LOGIN USER
         //	Facebook login library issues exception.
         //	Facebook returns an error
     } catch (FacebookRequestException $ex) {
         // When Facebook returns an error
         return new ViewModel(['error' => $ex->getMessage()]);
         //ERROR
         //	There was a more generic error
         //	When validation fails or other local issues
     }
     /*catch(\Exception $ex) {
       return new ViewModel(array(
//.........这里部分代码省略.........
开发者ID:bix0r,项目名称:Stjornvisi,代码行数:101,代码来源:AuthController.php


注:本文中的Facebook\FacebookRedirectLoginHelper::getReRequestUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。