last fm recent tracks
Here is a simple little PHP snippet I use to display the most recent tracks from my Last FM profile. The example below prints in a similar format to the list I have started including on the homepage.
Notes:
- This uses the curlContents function that you can grab from here.
- This also uses the PHP5 json_decode function. Peeps with older versions of PHP will need to either hunt down an alternative or UPGRADE!
- You will need to replace the YOUR_USER_NAME and YOUR_API_KEY values (obvs)
- $cache_file is the absolute path to a cache version of the html that is created. The file will need to have the usual read/write permissions.
- In this example I check to see if the cache file has been updated in the past 10 minutes (ie. 600 seconds) and if not - I update it. There is also a built-in $force_update to assist with testing.
← Go Home