A PHP XML parser for your listening data feeds from Last FM. I wrote my own because, I prefer the text-based listing on my page instead of the images provided by them.
Usage
Place the script somewhere in your PHP include path or in the same directory as the file you'll be invoking it from. For a quick overview:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head >
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Scrobbler XML Parser Sample</title>
</head>
<body>
<h1>Scrobbler XML Parser Sample Usage</h1>
<?php
define ("PATH_TO_SCROBBLER", "./scrobblerXMLParser.php");
define ("PATH_TO_XMLFILE", "./sample.xml");
require (PATH_TO_SCROBBLER);
// default output is UTF-8. You can specify ISO-8859-1 by invoking it as:
// $feed = new scrobblerXMLParser(CONF_ISO88591_OUTPUT);
$feed = new scrobblerXMLParser();
if ($feed->parse(PATH_TO_XMLFILE))
{
foreach ($feed->items->item as $item)
{
echo "<h3>Item</h3>\n<ul>\n";
echo "<li>title: " . $item['title'] . "</li>\n";
echo "<li>artist: " . $item['artist'] . "</li>\n";
echo "<li>link: " . $item['link'] . "</li>\n";
echo "<li>date: " . $item['date'] . "</li>\n";
echo "<li>mbid: " . $item['mbid'] . "</li>\n";
echo "<ul>\n";
}
}
?>
</body>
</html>
And its corresponding output. Likewise, using it after fetching the Recent Tracks XML for my account shows the latest tracks I've listened to.
Source is released under GPL and, like everyone else says, there's no warranty what-so-ever. Feel free to send comments or suggestions to edporras at gmail.com.
Change history
- scrobblerXMLParser v0.1 - Tue Nov 7 17:31:37 EST 2006: Rewrite for new XML data files.