rendered paste body 1. function lastfm_weekly_artists($user) {
2. $ch = curl_init();
3. $timeout = 5;
4. curl_setopt ($ch, CURLOPT_URL, "http://ws.audioscrobbler.com/1.0/user/$user/weeklyartistchart.xml");
5. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
6. curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
7. $url = curl_exec($ch);
8. curl_close($ch);
9. $xml = simplexml_load_string("$url");
10.
11. if (!isset($xml->artist)) {
12. echo "No stats to list.";
13. }
14.
15. else {
16. echo "<ul>\n";
17. for ( $i=0; $i<10; $i++) {
18. echo "<li><a href=\"" . $xml->artist[$i]->url . "\" title=\"$artist->name\">" . $xml->artist[$i]->name . "</a> - " . $xml->artist[$i]->playcount . "</li>\n";
19. }
20. echo "</ul>\n";
21. }
22. }