PHP/HTML/JavaScript app which displays currently playing song from Spotify along with additional information from LastFM.
When a song is not playing, app displays recently played tracks, total number of scrobbles etc.
-
Create an app on Spotify for Developers site
Note: make sure the Redirect URI is the same than the
SPOTIFY_REDIRECT_URI
below. -
Create API account on LastFM
Note: you can leave the Callback URL empty.
-
Create
/auth.php
file containing following information:<?php define('KIOSK', false); define('LASTFM_USER', 'YOUR-LASTFM-USERNAME'); define('LASTFM_API_KEY', 'YOUR-LASTFM-API-KEY'); define('SPOTIFY_CLIENT_ID', 'YOUR-CLIENT-ID'); define('SPOTIFY_CLIENT_SECRET', 'YOUR-CLIENT-SECRET'); define('SPOTIFY_REDIRECT_URI', '/spotify-callback/'); # Warning: Now Playing saves Spotify access tokens to the file below, # make sure it is in a secure place define('SPOTIFY_ACCESS_TOKENS_FILE_PATH', 'YOUR-PATH-TO-SPOTIFY-ACCESS-TOKENS');
-
Run Composer
php composer.phar install
or if you have Composer installed globallycomposer install
Composer installs Spotify Web API PHP. If you are not familiar with Composer, head to getcomposer.org.
I stumbled upon Jason Tate's raspberry-pi-now-playing which fetched currently playing song from LastFM and displayed it on a Hyperpixel screen. I started to make some little changes, and after a while I ended up adding Spotify API. Eventually I pretty much rewrote the whole thing.
Jason has great instructions how to get it (his version) running on a Raspberry Pi and Hyperpixel screen. Check that out.