/** * Exchange code for an access token. * * @see https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/v2.0#exchangecode * @param string $code The parameter received from the Login Dialog. * @param string $redirect_url 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. * @return 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); }