Gajus\Fuss\AccessToken::extend PHP Method

extend() public method

Upon successfully extending the token, the instance of the object is updated with the long-lived access token.
See also: https://developers.facebook.com/docs/facebook-login/access-tokens#extending
public extend ( ) : null
return null
    public function extend()
    {
        if ($this->type != self::TYPE_USER) {
            throw new Exception\AccessTokenException('Only user access token can be extended.');
        }
        if ($this->isLong()) {
            throw new Exception\AccessTokenException('Long-lived access token cannot be extended.');
        }
        $request = new \Gajus\Fuss\Request($this->app, 'GET', 'oauth/access_token', ['client_id' => $this->app->getId(), 'client_secret' => $this->app->getSecret(), 'grant_type' => 'fb_exchange_token', 'fb_exchange_token' => $this->access_token]);
        $response = $request->make();
        $this->access_token = $response['access_token'];
        $this->debugToken();
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @depends testExtendUserAccessToken
  * @expectedException Gajus\Fuss\Exception\AccessTokenException
  * @expectedExceptionMessage Long-lived access token cannot be extended.
  */
 public function testExtendLongLivedUserAccessToken(\Gajus\Fuss\AccessToken $access_token)
 {
     $access_token->extend();
 }