Spotify
in package
Spotify API wrapper
Table of Contents
- $accessToken : string
- $clientID : string
- $clientSecret : string
- $endpoint : string
- $timeout : int
- findArtist() : array<string|int, mixed>
- Search for artist
- findTrack() : array<string|int, mixed>
- Search for songs
- buildContext() : array<string|int, mixed>
- Build HTTP request
- generateColor() : string
- Generate a hex color
- generateRandomHex() : string
- Generate random hex
- parseHeaders() : array<string|int, mixed>
- Parse response headers
- send() : array<string|int, mixed>
- Send request to Spotify API
- setAccessToken() : void
- Get Spotify API access token
- setEnvVariables() : void
- Set endpoint URL and API key
Properties
$accessToken
private
string
$accessToken
Spotify access token
$clientID
private
string
$clientID
Spotify Client ID
$clientSecret
private
string
$clientSecret
Spotify Client Secret
$endpoint
private
string
$endpoint
Spotify endpoint
$timeout
private
int
$timeout
= 60
Request timeout
Methods
findArtist()
Search for artist
public
findArtist(string $name) : array<string|int, mixed>
Parameters
- $name : string
Return values
array<string|int, mixed> —findTrack()
Search for songs
public
findTrack(string $title) : array<string|int, mixed>
Parameters
- $title : string
Return values
array<string|int, mixed> —buildContext()
Build HTTP request
private
buildContext(string $method[, array<string|int, mixed>|null $data = null ]) : array<string|int, mixed>
Parameters
- $method : string
- $data : array<string|int, mixed>|null = null
Return values
array<string|int, mixed> —generateColor()
Generate a hex color
private
generateColor() : string
Return values
string —generateRandomHex()
Generate random hex
private
generateRandomHex() : string
Return values
string —parseHeaders()
Parse response headers
private
parseHeaders(array<string|int, mixed> $headers) : array<string|int, mixed>
Parameters
- $headers : array<string|int, mixed>
Return values
array<string|int, mixed> —send()
Send request to Spotify API
private
send(string $uri, string $method[, array<string|int, mixed>|null $data = null ]) : array<string|int, mixed>
Parameters
- $uri : string
- $method : string
- $data : array<string|int, mixed>|null = null
Return values
array<string|int, mixed> —setAccessToken()
Get Spotify API access token
private
setAccessToken() : void
Return values
void —setEnvVariables()
Set endpoint URL and API key
private
setEnvVariables() : void