PHP Class SpotifyWebAPI\Session

Show file Open project: jwilsson/spotify-web-api-php Class Usage Examples

Protected Properties

Property Type Description
$accessToken
$clientId
$clientSecret
$expirationTime
$redirectUri
$refreshToken
$request

Public Methods

Method Description
__construct ( string $clientId, string $clientSecret, string $redirectUri = '', Request $request = null ) Constructor Set up client credentials.
getAccessToken ( ) : string Get the access token.
getAuthorizeUrl ( array | object $options = [] ) : string Get the authorization URL.
getClientId ( ) : string Get the client ID.
getClientSecret ( ) : string Get the client secret.
getRedirectUri ( ) : string Get the client's redirect URI.
getRefreshToken ( ) : string Get the refresh token.
getTokenExpiration ( ) : integer Get the access token expiration time.
refreshAccessToken ( string $refreshToken ) : boolean Refresh an access token.
requestAccessToken ( string $authorizationCode ) : boolean Request an access token given an authorization code.
requestCredentialsToken ( array $scope = [] ) : boolean Request an access token using the Client Credentials Flow.
setClientId ( string $clientId ) : void Set the client ID.
setClientSecret ( string $clientSecret ) : void Set the client secret.
setRedirectUri ( string $redirectUri ) : void Set the client's redirect URI.

Method Details

__construct() public method

Constructor Set up client credentials.
public __construct ( string $clientId, string $clientSecret, string $redirectUri = '', Request $request = null )
$clientId string The client ID.
$clientSecret string The client secret.
$redirectUri string Optional. The redirect URI.
$request Request Optional. The Request object to use.

getAccessToken() public method

Get the access token.
public getAccessToken ( ) : string
return string The access token.

getAuthorizeUrl() public method

Get the authorization URL.
public getAuthorizeUrl ( array | object $options = [] ) : string
$options array | object Optional. Options for the authorization URL. - array scope Optional. Scope(s) to request from the user. - boolean show_dialog Optional. Whether or not to force the user to always approve the app. Default is false. - string state Optional. A CSRF token.
return string The authorization URL.

getClientId() public method

Get the client ID.
public getClientId ( ) : string
return string The client ID.

getClientSecret() public method

Get the client secret.
public getClientSecret ( ) : string
return string The client secret.

getRedirectUri() public method

Get the client's redirect URI.
public getRedirectUri ( ) : string
return string The redirect URI.

getRefreshToken() public method

Get the refresh token.
public getRefreshToken ( ) : string
return string The refresh token.

getTokenExpiration() public method

Get the access token expiration time.
public getTokenExpiration ( ) : integer
return integer A Unix timestamp indicating the token expiration time.

refreshAccessToken() public method

Refresh an access token.
public refreshAccessToken ( string $refreshToken ) : boolean
$refreshToken string The refresh token to use.
return boolean Whether the access token was successfully refreshed.

requestAccessToken() public method

Request an access token given an authorization code.
public requestAccessToken ( string $authorizationCode ) : boolean
$authorizationCode string The authorization code from Spotify.
return boolean True when the access token was successfully granted, false otherwise.

requestCredentialsToken() public method

Request an access token using the Client Credentials Flow.
public requestCredentialsToken ( array $scope = [] ) : boolean
$scope array Optional. Scope(s) to request from the user.
return boolean True when an access token was successfully granted, false otherwise.

setClientId() public method

Set the client ID.
public setClientId ( string $clientId ) : void
$clientId string The client ID.
return void

setClientSecret() public method

Set the client secret.
public setClientSecret ( string $clientSecret ) : void
$clientSecret string The client secret.
return void

setRedirectUri() public method

Set the client's redirect URI.
public setRedirectUri ( string $redirectUri ) : void
$redirectUri string The redirect URI.
return void

Property Details

$accessToken protected property

protected $accessToken

$clientId protected property

protected $clientId

$clientSecret protected property

protected $clientSecret

$expirationTime protected property

protected $expirationTime

$redirectUri protected property

protected $redirectUri

$refreshToken protected property

protected $refreshToken

$request protected property

protected $request