In order to get Spotify now playing you must first enable Last.fm scrobbling inside your Spotify settings and sync it with your last.fm account.
Make sure to fill in the user and api key which you can get from here.
You must place the file inside your /var/www/html
directory and name it something such as currentsong.php
or song.php
Then, from Twitch chat, you can add a command like this:
!addcom !currentsong Current Song: (customapi thentypeyourwebsiteIPordomainnamehere)
As of version 2.3.5.2 you can do this all through a customapijson command and no longer need an external script, there has been an enhancement made to JSON parsing that allows for this:
!addcom command_name_you_want (customapijson http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=USER_ID&api_key=API_KEY&limit=1&format=json recenttracks.track.0.name { by } recenttracks.track.0.artist.#text)