logo AlexBio's Blog /dev/random

<?php
/*
    Retrieve last song scrobbled in Last.fm.
 
    Copyright 2009 Alessandro Ghedini
    --------------------------------------------------------------
    "THE BEER-WARE LICENSE" (Revision 42):
    Alessandro Ghedini wrote this file. As long as you retain this 
    notice you can do whatever you want with this stuff. If we 
    meet some day, and you think this stuff is worth it, you can 
    buy me a beer in return.
    --------------------------------------------------------------
*/
 
$user = "Al3xBio";
$url = "http://ws.audioscrobbler.com/1.0/user/$user/recenttracks.txt";
 
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$src = curl_exec($c);
curl_close($c);
 
$src = str_replace('–', '-', $src);
$songs = preg_split('/[\r\n]+/', $src, -1, PREG_SPLIT_NO_EMPTY);
list ($timeartist, $title) = split ('[-]', $songs[0]);
list ($time, $artist) = split ('[,]', $timeartist);
 
echo "<img src='http://img301.imageshack.us/img301/3972/lastfmz.png' 
	align='absmiddle' /> <a href='http://www.last.fm/music/
	$artist/_/$title'target='_blank'>$artist - $title</a>";
 
?>


Spread Firefox Affiliate Button