I was trying to incorporate last.fm feeds for the profile page of an arbitrary set of users using the codeigniter framework and this
simple last fm library. It worked perfectly within minutes. The hard part was, making sure that the entered username was indeed a valid last.fm username. This was the resulting callback function that eventually was discovered.
function lastfm_check($lastfmname){
$this->validation->set_message('lastfm_check', 'This does not appear to be a valid last.fm username.');
$contents = @file_get_contents($url);
$url = "http://ws.audioscrobbler.com/1.0/user/".$lastfmname."/recenttracks.rss";
return !empty($contents);
}
This works as the last.fm feed url is always valid, but if the username does not exist, it simply echoes: No user exists with this name.