tags:

views:

34

answers:

2

There's a status indicator code for AIM which returns two different images depending on your status (on/offline) which was done in PHP and with the AIM API.

<img src="http://big.oscar.aol.com/USERNAME?on_url=ON_IMAGE&amp;off_url=OFF_IMAGE"&gt;

I was looking for a Last.fm widget that shows JUST the album cover I'm listening to or the last album I listened to, but couldn't find it.

How do I go along making it using PHP and the Last.fm API.

+1  A: 

isn't http://www.lastfm.pl/api/show?service=290 enough? Simply parse XML you got as response, and use data extracted from "image" tags.

migajek
A: 

Well as I see it and will do it probably in python: You have the user user.getRecentTracks, where you can get:

<recenttracks user="RJ" page="1" perPage="10" totalPages="3019">
  <track nowplaying="true">
    <artist mbid="2f9ecbed-27be-40e6-abca-6de49d50299e">Aretha Franklin</artist>
    <name>Sisters Are Doing It For Themselves</name>
    <mbid/>
    <album mbid=""/>
    <url>www.last.fm/music/Aretha+Franklin/_/Sisters+Are+Doing+It+For+Themselves</url>
    <date uts="1213031819">9 Jun 2008, 17:16</date>
    <streamable>1</streamable>
  </track>
  ...
</recenttracks>

Then you have the api call artist.getInfo (the same as album.getInfo), where you can get:

<artist>
  <name>Cher</name>
  <mbid>bfcc6d75-a6a5-4bc6-8282-47aec8531818</mbid>
  <url>http://www.last.fm/music/Cher&lt;/url&gt;
  <image size="small">http://userserve-ak.last.fm/serve/50/285717.jpg&lt;/image&gt;
  <image size="medium">http://userserve-ak.last.fm/serve/85/285717.jpg&lt;/image&gt;
  <image size="large">http://userserve-ak.last.fm/serve/160/285717.jpg&lt;/image&gt;
  <streamable>1</streamable>

You'll need only an XML parse to get the images (or just use RegEx). Calling the API you can make with curl request:

For the user info: e.g.: http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&amp;user=rj&amp;api_key=b25b959554ed76058ac220b7b2e0a026

For the Album Info you can get the Idea witch is in the examples in the link you provided.

VKolev