* @throws TokenResponseException */ protected function parseRequestTokenResponse($responseBody) { parse_str($responseBody, $data); if (!isset($data) || !is_array($data)) { throw new TokenResponseException('Unable to parse response.'); } else if (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] != 'true') { throw new TokenResponseException('Error in retrieving token.'); } $data['is_request_token'] = true; return $this->parseAccessTokenResponse($data); } /** * @param string|array $responseBody * @return StdOAuth1Token
{ $authorizationHeader = array('Authorization' => $this->buildAuthorizationHeaderForTokenRequest()); $headers = array_merge($authorizationHeader, $this->getExtraOAuthHeaders()); $responseBody = $this->httpClient->retrieveResponse($this->getRequestTokenEndpoint(), array(), $headers); $token = $this->parseRequestTokenResponse($responseBody); $this->storage->storeAccessToken($this->service(), $token); return $token; } /**
$this->authenticated = true; } else if ($proxy->hasValidAccessToken()) { $this->authenticated = true; } else { // extra request needed for oauth1 to request a request token :-) $token = $proxy->requestRequestToken(); /** @var $url Uri */ $url = $proxy->getAuthorizationUri(array('oauth_token' => $token->getRequestToken())); \Yii::$app->getResponse()->redirect($url->getAbsoluteUri(), 301)->send(); } } catch (\OAuthException $e) { throw new ErrorException($e->getMessage(), $e->getCode(), 1, $e->getFile(), $e->getLine(), $e);
$eauth->setCancelUrl(\Yii::$app->getUrlManager()->createAbsoluteUrl([$redirectUrl])); $redirectUrl = null; if(!\Yii::$app->user->isGuest) { $redirectUrl = $eauth->getRedirectUrl(); } try { if ($eauth->authenticate()) { $identity = UserIdentity::findByEAuth($eauth); \Yii::$app->getUser()->login($identity); if (\Yii::$app->request->cookies->get('current_url')) $url = \Yii::$app->request->cookies->get('current_url')->value;
$args = $this->controller->bindActionParams($this, $params); Yii::debug('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
$params = $this->catchAll; unset($params[0]); } try { Yii::debug("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
{ try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
defined('YII_DEBUG') or define('YII_DEBUG', $env->yiiDebug); defined('YII_ENV') or define('YII_ENV', $env->yiiEnv); require(__DIR__ . '/../vendor/autoload.php'); require_once($env->yiiPath); $env->runYiiStatics(); (new yii\web\Application($env->configWeb))->run();
$_GET = [ 'service' => 'twitter', 'redirect' => '/', ]; $_SESSION = [ '__flash' => [], ];