PHP code example of jordanpartridge / spotify-client
1. Go to this page and download the library: Download jordanpartridge/spotify-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jordanpartridge / spotify-client example snippets
use Jordanpartridge\SpotifyClient\Contracts\SpotifyClientInterface;
// Inject the client (Laravel's DI is sweeter than tea)
public function __construct(SpotifyClientInterface $spotify)
{
$this->spotify = $spotify;
}
// Get an album (data comes back clean as mountain air)
$album = $this->spotify->albums()->get('album-id');
// Search for artists (find 'em faster than a hound dog)
$artists = $this->spotify->artists()->getMultiple(['artist1', 'artist2']);
// Get track details (metadata richer than bottom land)
$track = $this->spotify->tracks()->get('track-id');
// Configure in your .env
SPOTIFY_CLIENT_ID=your_client_id
SPOTIFY_CLIENT_SECRET=your_client_secret
SPOTIFY_AUTH_FLOW=client_credentials
// The install command will help you set this up
SPOTIFY_AUTH_FLOW=authorization_code
SPOTIFY_REDIRECT_URI=http://localhost:8000/callback
// config/spotify-client.php
return [
'client_id' => env('SPOTIFY_CLIENT_ID'),
'client_secret' => env('SPOTIFY_CLIENT_SECRET'),
'default_market' => env('SPOTIFY_DEFAULT_MARKET', 'US'),
// ... and much more
];
bash
php artisan spotify:install
# or use the setup alias
php artisan spotify:setup
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.