Skip to content

Instantly share code, notes, and snippets.

@tjhole
Created December 3, 2013 12:37
Show Gist options
  • Save tjhole/7768514 to your computer and use it in GitHub Desktop.
Save tjhole/7768514 to your computer and use it in GitHub Desktop.
PHP: Lastfm - months top artists
This month we have been listening to
<?php
$username = 'tomhole1986';
$itemCount = 5;
$month = 1;
$scrobbler_url = "http://ws.audioscrobbler.com/2.0/user/" . $username . "/topartists.xml?period=" . $month . "month&limit=" . $itemCount . "";
$scrobbler_cache_file = 'scrobbler_' . $username . '_data.cache';
if ($scrobbler_xml = file_get_contents($scrobbler_url)) {
$scrobbler_data = simplexml_load_string($scrobbler_xml);
foreach ($scrobbler_data->artist as $track) {
$string = '';
$string .= $track->name;
$string .= ', ';
echo $string;
}
} ?> on Spotify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment