fmTuner: A Last.fm Plugin for WordPress

fmTuner is a WordPress plugin for retrieving song details from your Last.fm profile and publishing them anywhere in your WordPress theme. It provides options for choosing among your Recent, Loved, or Top tracks, as well as tools to adjust the update frequency and appearance.

Of particular note is the customizable Display Format option. Using simple tags like [::artist::] and [::image::] intermixed with regular HTML, you can tweak your Last.fm tracks exactly how you like, or however your WordPress theme requires. You have full control!

Download

Download the latest fmTuner from WordPress.org

Requirements

  • WordPress 2.7 or newer.
  • PHP 5 or newer
  • Basic knowledge of PHP, HTML, and WordPress.

Installation

  • Upload fmtuner.php to a directory inside /wp-content/plugins/ directory. For example: /wp-content/plugins/fmtuner/fmtuner.php
  • Ensure /wp-content/plugins/fmtuner/ is writable by your webserver.
  • Activate the plugin through the “Plugins” menu in WordPress.
  • Set up options in the “Settings” menu in WordPress.
  • Place the PHP code if(function_exists('fmtuner')) { fmtuner(); } in your templates, to call up fmTuner.

Release History

  • fmTuner 1.1
    Released on Feb. 1, 2010
    Added a placeholder image field to the fmTuner Settings page, which will be substituted when tracks have no artwork.
    Tested under WordPress 2.9.1.
  • fmTuner 1.0.8
    Released on Nov. 3, 2009
    Fixed a bug with the [::url::] fmTuner tag that caused Last.fm links to appear incorrectly.
  • fmTuner 1.0.7
    Released on Apr. 23, 2009
    Tracks with foreign character sets now display more accurately.
  • fmTuner 1.0.6
    Released on Mar. 29, 2009
    You can now display more than 10 Recent Tracks, and you should get fewer tracks without artwork.
  • fmTuner 1.0.5
    Released on Mar. 22, 2009
    Track information is now properly escaped to handle $ signs, quotes, and other non-alphanumeric characters.
  • fmTuner 1.0.4
    Released on Dec. 14, 2008
    Made minor tweaks for fmTuner Settings page under WordPress 2.7.
  • fmTuner 1.0.3
    Released on Nov. 15, 2008
    By request, a [::number::] fmTuner tag has been added, which emits a sequential number for each track (starting at 1). This is particularly useful for CSS and JavaScript display purposes.
  • fmTuner 1.0.2
    Released on Oct. 5, 2008
    Added a cURL-based alternative to file_get_contents to hopefully resolve “URL file-access is disabled” issues. If allow_url_fopen is disabled in the php.ini, cURL will be used to fetch the Last.fm feed instead.
  • fmTuner 1.0.1
    Released on Sept. 9, 2008
    Added better failure checking and informational messages, removed development code, and updated instructions.
  • fmTuner 1.0
    Released on Sept. 6, 2008
    Initial release.
fmTuner: A Last.fm Plugin for WordPress

93 thoughts on “fmTuner: A Last.fm Plugin for WordPress

  1. Nice, altough it has the same problem as every other Last.fm-Plugin that i know: I have to choose what to display in the settings.

    Why not make this an parameter to fmtuner();?
    That way i could easily display everything i want using only one plugin.

    I have described it in more detail in the comments over there: http://leandrow.net/ilastfm-lastfm-wordpress-plugin/#comments

    Any chance you’ll be adding “top tracks”, “top artists”, “top albums” etc and giving us the opportunity to display multiple instances by using it like:

    ===

    My Top Tracks:
    fmtuner(‘tracks’);

    My Favorite Albums:
    fmtuner(‘albums’);

    I’m a fan of:
    fmtuner(‘artists’);

    ===

    That would easily make your Last.fm-Plugin THE outstanding one out there.

    Like

  2. @AgentSmith: That’s a good point! I had assumed it would only be used in one place, but with an added parameter, it could be used multiple times on a site, each with different options.

    You can currently choose Top Tracks, but not the other two.

    I’ll see what I can cook up :)

    Like

  3. I keep getting this error.
    Fatal error: Call to undefined function: file_put_contents() in /homepages/42/d161646578/htdocs/home/wp-content/plugins/fmtuner/fmtuner.php on line 237

    Like

  4. @Collin: “only tracks with artwork will be shown” is a dangerous option. My case was that no artwork-powered tracks were cached and thus zero output produced.

    Still thanks for a great plug.

    Like

  5. A FAQ for this might be nice. For example… i got an error message telling me:

    Settings Saved – syled nicely… then in plain text underneath >
    Call to undefined function: file_put_contents() in /homepages/15/d117163260/htdocs/wordpress/wp-content/plugins/fmtuner/fmtuner.php on line 237

    I put the php code in my sidebar include BEFORE any of the if statments for widgets — just to be safe.

    Like

  6. @Jake @Joel_: file_put_contents() is a PHP 5 function. Are you by chance running PHP < 5?

    The WordPress plugin page linked to above has a small FAQ that is due for some updating now that the plugin is in the wild :) I'll be updating it soon with solutions and problems covered in comments here.

    Like

  7. fmTuner: A Last.fm Plugin for WordPress…

    fmTuner is a small WordPress plugin for retrieving song details from your Last.fm profile and publishing them anywhere in your WordPress theme. It provides options for choosing among your Recent, Loved, or Top tracks, as well as tools to adjust the upd…

    Like

  8. I plan on porting it to PHP 4 for a future release, as the dependency on PHP 5 is solely for the XML parsing that comes built-in. It shouldn’t be terribly complicated to find (or write) a basic XML parser for PHP 4 and get things rolling :)

    Like

  9. actually, i did find out how to activate php5 for 1and1 hosting… but it turns out the php init settings do not support that external URL call you make… (even though it might very well handle the xml parsing).

    Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /homepages/15/d117163260/htdocs/wordpress/wp-content/plugins/fmtuner/fmtuner.php on line 248

    somehow, I doubt there would be a work-around for this… I’m pretty much stuck with the PHP config my host gives me, right? Any thoughts?

    Like

  10. @Joel_: You might be able to drop in an ini_set() call before file_get_contents() is called: ini_set(‘allow_url_fopen’, ‘on’);

    Otherwise, you might have to get in touch with 1and1 to see if they can update your config…

    Like

  11. The plugin does not work for me…
    Yes, I am running PHP5. WordPress 2.6.2

    Nothing will show up in the template. I get this at the top of my fmTuner settings page:

    ==================

    Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /mnt/local/home/jomilla/jomilla.com/wp-content/plugins/fmtuner/fmtuner.php on line 248

    Warning: file_get_contents(http://ws.audioscrobbler.com/2.0/?method=user.gettoptracks&user=jomilla&api_key=ff0eaca3b7e2660755d6c652af7b0489) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /mnt/local/home/jomilla/jomilla.com/wp-content/plugins

    =====================

    Like

  12. @Jordan: It seems your web host has URL-based file access turned off for some reason. You can try the ini_set solution I gave to Joel (above), and if all else fails, your web host might be able to turn it on.

    Like

  13. And I got this back from my hosting company for the record:
    Hello Jordan,

    The reason this is disabled is because there is a security issue with URL
    based file access specifically url_file_open.

    We can’t change the global PHP settings, but you’re more than welcome to
    install a custom PHP instance if you’d like:

    http://wiki.dreamhost.com/Custom_PHP.ini

    I apologize for the inconvenience.

    Like

  14. Hi,

    can’t get the plugin running! Cache correctly downloaded, but
    no output.

    I placed

    in my SIDEBAR.PHP. No output. Where do i have to place the
    function-phrase and how cant i customize the output?

    Sven

    Like

  15. Hey any chance on telling us how to style these like yours I want mine to look simelar but I can’t get it quite right. :P great plugin btw exactly what I needed

    Like

  16. I am not familiar with PHP. Any step by step instructions for getting this into the sidebar? It doesn’t seem like it would be too difficult but I have yet to get anything to display. I do know it is installed correctly.

    Like

  17. @Scott @Dave: Once fmTuner is installed, activated, and set up (enter your Last.fm username in the fmTuner Settings page), open up /wp-content/themes/default/sidebar.php with a text editor like Notepad or TextMate. Around line 53, add in:
    <li><h2>Tunes</h2>
    <ul>
    <?php if(function_exists('fmtuner')) { fmtuner(); } ?>
    </ul>
    </li>

    Save the file, and reload your blog in a web browser. This will call up fmTuner within your sidebar!

    Like

  18. Hey Collin,

    have you looked into my comment/request from Sep 08 yet? Any chance you’ll be doing it?
    If not, would you mind if I used you plugin as a basis for doing it myself with possibly re-releasing it?

    Late happy new year to you! :)

    Like

  19. @AgentSmith: I haven’t yet. If you’re feeling ambitious, go right ahead with your modifications. I’d appreciate a link anywhere on the finished version, but it’s not required :)

    @Violet: Cool — great writeup! Thanks for the links, too. I’m glad fmTuner is working out for you.

    Like

  20. @boogieboa: fmTuner will work on pages, posts, etc. — just about any WordPress-handled template. Since song data is cached, it doesn’t hit Last.fm every time, keeping your site snappy.

    Like

  21. I’m unable to get the tuner to work on my website… I’m using the code supplied and it doesn’t display anything! please advise

    I am using the latest version of wordpress

    Like

  22. @boogieboa: The tags won’t work within a post; They only work with fmTuner’s settings. In the fmTuner settings screen, you use the tags among HTML to build the layout for each displayed track.

    Then, wherever you insert if(function_exists('fmtuner')) { fmtuner(); } (between PHP tags), the list of tracks will get displayed. You can even use this call inside index.php or single.php to display your tracks in every post.

    @Nate: Any idea which version of PHP you’re using?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s