コード例 #1
0
ファイル: AuthAction.php プロジェクト: songhongyu/idaiyan
 /**
  * Performs OAuth1 auth flow.
  * @param OAuth1 $client auth client instance.
  * @return Response action response.
  */
 protected function authOAuth1($client)
 {
     // user denied error
     if (isset($_GET['denied'])) {
         return $this->redirectCancel();
     }
     if (isset($_REQUEST['oauth_token'])) {
         $oauthToken = $_REQUEST['oauth_token'];
     }
     if (!isset($oauthToken)) {
         // Get request token.
         $requestToken = $client->fetchRequestToken();
         // Get authorization URL.
         $url = $client->buildAuthUrl($requestToken);
         // Redirect to authorization URL.
         return Yii::$app->getResponse()->redirect($url);
     } else {
         // Upgrade to access token.
         $client->fetchAccessToken();
         return $this->authSuccess($client);
     }
 }