UserHandler
extends BaseHandler
in package
Table of Contents
Properties
- $accessToken : string|null
- $baseUrl : string
- $client : Client
- $credentialService : SpotifyCredentialService|null
Methods
- __construct() : mixed
- getCurrentUser() : array<string|int, mixed>
- Get current user's profile
- getRecentlyPlayed() : array<string|int, mixed>
- Get user's recently played tracks
- getSavedTracks() : array<string|int, mixed>
- Get user's saved tracks
- getTopArtists() : array<string|int, mixed>
- Get user's top artists
- getTopTracks() : array<string|int, mixed>
- Get user's top tracks
- getUserPlaylists() : array<string|int, mixed>
- Get user's playlists
- setAccessToken() : void
- Set the access token
- setCredentialService() : void
- Set the credential service
- getAccessToken() : string|null
- Get the current access token
- getAuthHeaders() : array<string|int, mixed>
- Get authorization headers
- makeRequest() : array<string|int, mixed>
- Make an authenticated request
Properties
$accessToken
protected
string|null
$accessToken
= null
$baseUrl read-only
protected
string
$baseUrl
$client read-only
protected
Client
$client
$credentialService
protected
SpotifyCredentialService|null
$credentialService
= null
Methods
__construct()
public
__construct(Client $client, string $baseUrl) : mixed
Parameters
- $client : Client
- $baseUrl : string
getCurrentUser()
Get current user's profile
public
getCurrentUser() : array<string|int, mixed>
Return values
array<string|int, mixed>getRecentlyPlayed()
Get user's recently played tracks
public
getRecentlyPlayed([int $limit = 20 ][, int|null $after = null ][, int|null $before = null ]) : array<string|int, mixed>
Parameters
- $limit : int = 20
- $after : int|null = null
- $before : int|null = null
Return values
array<string|int, mixed>getSavedTracks()
Get user's saved tracks
public
getSavedTracks([int $limit = 20 ][, int $offset = 0 ][, string|null $market = null ]) : array<string|int, mixed>
Parameters
- $limit : int = 20
- $offset : int = 0
- $market : string|null = null
Return values
array<string|int, mixed>getTopArtists()
Get user's top artists
public
getTopArtists([string $timeRange = 'medium_term' ][, int $limit = 20 ][, int $offset = 0 ]) : array<string|int, mixed>
Parameters
- $timeRange : string = 'medium_term'
- $limit : int = 20
- $offset : int = 0
Return values
array<string|int, mixed>getTopTracks()
Get user's top tracks
public
getTopTracks([string $timeRange = 'medium_term' ][, int $limit = 20 ][, int $offset = 0 ]) : array<string|int, mixed>
Parameters
- $timeRange : string = 'medium_term'
- $limit : int = 20
- $offset : int = 0
Return values
array<string|int, mixed>getUserPlaylists()
Get user's playlists
public
getUserPlaylists([string|null $userId = null ][, int $limit = 20 ][, int $offset = 0 ]) : array<string|int, mixed>
Parameters
- $userId : string|null = null
- $limit : int = 20
- $offset : int = 0
Return values
array<string|int, mixed>setAccessToken()
Set the access token
public
setAccessToken(string|null $accessToken) : void
Parameters
- $accessToken : string|null
setCredentialService()
Set the credential service
public
setCredentialService(SpotifyCredentialService $credentialService) : void
Parameters
- $credentialService : SpotifyCredentialService
getAccessToken()
Get the current access token
protected
getAccessToken() : string|null
Return values
string|nullgetAuthHeaders()
Get authorization headers
protected
getAuthHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed>makeRequest()
Make an authenticated request
protected
makeRequest(string $method, string $endpoint[, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
- $method : string
- $endpoint : string
- $options : array<string|int, mixed> = []