New JSON Feed for Recent Tracks
Friday January 2, 2009 1:14 AM
We just added a JSON formatted feed for recent tracks to make manipulation with JavaScript easier. The JSON feeds work lust like the recent tracks feeds:
Full feed: http://zenradar.roblogic.net/service/1.0/user/[username]/recenttracks.json
Specify number of results (1-10): http://zenradar.roblogic.net/service/1.0/user/[username]/recenttracks_[1-10].json
Here's the easy way to cache the feed on your site. Run this script from cron on a regular basis, then pull the cached file in your JavaScript to keep things snappy.
Full feed: http://zenradar.roblogic.net/service/1.0/user/[username]/recenttracks.json
Specify number of results (1-10): http://zenradar.roblogic.net/service/1.0/user/[username]/recenttracks_[1-10].json
Here's the easy way to cache the feed on your site. Run this script from cron on a regular basis, then pull the cached file in your JavaScript to keep things snappy.
<?php
//from marc2003's script on last.fm forum
$user = 'roblogic'; //last.fm username
$remotefile = "http://zenradar.roblogic.net/service/1.0/user/$user/
recenttracks.json";
$localfile = $user.'.json';
try
{
$ch = curl_init($remotefile);
$fp = fopen($localfile, "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
}
catch (Exception $e)
{
echo $e->getMessage();
echo '<pre>';
echo $e->getTraceAsString();
echo '</pre>';
}Context: ZR Development

