Bindings to libspotify (focus on manipulating playlists) wrapped in a PHP extension.
C
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README.md
album.c
artist.c
config.m4
php_spotify.h
playlist.c
spotify.c
track.c
user.c

README.md

Experimental libspotify PHP lib

Important notes

  • Read the libspotify license, there are some important things to note; for example you CAN NOT "attempt to embed or integrate the API into any website or otherwise allow access to the Service via the web rather than via the Application.".
  • The behaviour and API might change; this library is not production ready.

Installation

  • Install the libspotify dev files and binary that fits your system, get them from the Spotify developer website.
  • Run these commands: phpize; ./configure --enable-spotify; make && make install

Usage

$spotify = new Spotify("/path/to/key.file", "username", "password");

$coolTrack = $spotify->getTrackByURI('spotify:track:6JEK0CvvjDjjMUBFoXShNZ');
 
// List all playlists
$playlists = $spotify->getPlaylists(); // returns array of SpotifyPlaylist
foreach ($playlists as $playlist) {
	printf("%s (%d tracks, by %s)\n", $playlist, $playlist->getNumTracks(), %playlist->getOwner());

	foreach ($playlist->getTracks() as $track) {
		$duration = $track->getDuration();
		printf("  -> %s - %s [%02d:%02d]\n", $track->getArtist(), $track,
				$duration/60, $duration%60);
	}

	// and add a important piece of music
	$playlist->addTrack($coolTrack, 0 /*position*/);
}

Credits

Vilhelm K. Vardøy vilhelmkv@gmail.com