public static makeFromCode ( |
||
$app | ||
$code | string | The parameter received from the Login Dialog. |
$redirect_url | string | This argument is required and must be the same as the original request_uri that you used when starting the OAuth login process. In case of FB.login, it is empty string. |
리턴 | Gajus\Fuss\AccessToken |
public static function makeFromCode(\Gajus\Fuss\App $app, $code, $redirect_url = '')
{
$request = new \Gajus\Fuss\Request($app, 'GET', 'oauth/access_token', ['client_id' => $app->getId(), 'client_secret' => $app->getSecret(), 'redirect_uri' => $redirect_url, 'code' => $code]);
$response = $request->make();
return new \Gajus\Fuss\AccessToken($app, $response['access_token'], \Gajus\Fuss\AccessToken::TYPE_USER);
}
/** * Resolve the user access token from the signed request. * The access token is either provided or it can be exchanged for the code. * * @return null|Gajus\Fuss\AccessToken */ public function getAccessToken() { if (!$this->access_token) { if (isset($this->signed_request['oauth_token'])) { $this->access_token = new \Gajus\Fuss\AccessToken($this->app, $this->signed_request['oauth_token'], \Gajus\Fuss\AccessToken::TYPE_USER); } else { if (isset($this->signed_request['code'])) { $this->access_token = \Gajus\Fuss\AccessToken::makeFromCode($this->app, $this->signed_request['code']); } } } return $this->access_token; }