marc2003 said: i have no idea what script you are using but this little snippet fetches the last 10 tracks and displays the same results as you want. it also has caching support. :)
<?php $user = 'marc2003'; $cache = 120; //in seconds, how long to cache data locally $remotefile = "http://ws.audioscrobbler.com/1.0/user/$user/recenttracks.xml"; $localfile = $user.'.xml'; if ((!file_exists($localfile)) || (time()-filemtime($localfile)>$cache)) { $contents = @file_get_contents($remotefile); $fp = fopen($localfile, "w"); fwrite($fp, $contents); fclose($fp); } $xml = @simplexml_load_file($localfile); for ($t = 0; $t <= 9; $t++) { echo "<li>".$xml->track[$t]->artist." - ".$xml->track[$t]->name."</li>"; } ?>
thanks mark2003 but, cache is empty! perhaps, file_get_contents disabled any idea??
dukny said: thanks mark2003 but, cache is empty! perhaps, file_get_contents disabled any idea??
well your "recenttracks.xml" file on lastfm is empty. nothing the script can do about that!! just scrobble some more tracks and fill it up again. or maybe lastfm is a little behind and it's temporarily not showing your recent suubmissions?
the code i posted certainly works on my username at this minute in time....
i'm also using the same, albeit slightly more advanced code for my signature.
marc2003 said: dukny said: thanks mark2003 but, cache is empty! perhaps, file_get_contents disabled any idea??
well your "recenttracks.xml" file on lastfm is empty. nothing the script can do about that!! just scrobble some more tracks and fill it up again. or maybe lastfm is a little behind and it's temporarily not showing your recent suubmissions?
the code i posted certainly works on my username at this minute in time.... i'm also using the same, albeit slightly more advanced code for my signature.
hmm... yes, my "recnttracks.xml" is empty. i use to roblogic (another user name) what problem? my server is php4.4.2
well your "recenttracks.xml" file on lastfm is empty. nothing the script can do about that!! just scrobble some more tracks and fill it up again. or maybe lastfm is a little behind and it's temporarily not showing your recent suubmissions?
try another username and you can see it working. :)
edit: you've barely scrobbled any tracks this week.
Well i'm triyin with my friend xcuntx which have some files but it changes anything.... :/ look here : http://www.visual-music.org/infos.php and http://www.visual-music.org/scripts/get_lastfm.php which contains this : <?php $user = 'xcuntx'; $cache = 120; //in seconds, how long to cache data locally $remotefile = "http://ws.audioscrobbler.com/1.0/user/$user/recenttracks.xml"; $localfile = $user.'.xml'; if ((!file_exists($localfile)) || (time()-filemtime($localfile)>$cache)) { $contents = @file_get_contents($remotefile); $fp = fopen($localfile, "w"); fwrite($fp, $contents); fclose($fp); } $xml = @simplexml_load_file($localfile); for ($t = 0; $t <= 9; $t++) { echo "<li>".$xml->track[$t]->artist." - ".$xml->track[$t]->name."</li>"; } ?>
maybe it's a permissions issue? the script will need write access to the server to create the local xml file? maybe you can test simplexml is working by bypassing the caching for now and reading directly from lastfm?
Well I chmod to 755 ant try your script and it doesn't work
I try without the @ and here is my warnings : Warning: file_get_contents(http://ws.audioscrobbler.com/1.0/user/xcuntx/recenttracks.xml) [function.file-get-contents]: failed to open stream: No route to host in /home/xxx/get_lastfm.php on line 276
So it's the file_get_contents which doesnt work...
It seems to be a server configuration problem but I don't know which option I have to activate
I made some test and it seems like if I try to access to a copy of the audioscrobbler xml file I made on an other server it works. But it doesnt works for xml file from audioscrobbler really strange...
astoever said: @moe2i6: The script is intended to use in conjunction with a webpage. You need a site that supports PHP and then include the script where you want the Last.FM info to be displayed. Like with PHP you'd write <? include 'scriptname'; ?> in the page you'd want it running. You can see it in action on http://www.astoever.no
FIRST: I don't see any 'Recent Tracks' listed at the URI you provided: http://www.astoever.no
SECOND: When you give the example of <? include 'scriptname'; ?> what do I put in for 'scriptname'?
if (round($days, 0) == "1") { echo "<br /><span class=\"time\">".round($days, 0)." day ago</span></li>"; } else { echo "<br /><span class=\"time\">".round($days, 0)." days ago</span></li>"; }
}
// $timestamp = date('j. n. Y, H:i:s',$trackArray[0]); } echo $wrapperEnd; }
(if you want to try, replace this with the end of the code; note "echo $wrapperEnd; -> replace the original ending with this...)
the Code is yet under construction. I'll develop it a bit but yet decided to tell this...
Btw what's the point with question marks between the artist and song (for example "Dream Theater ? Octavarium"). I split those because I wanted them to be on different lines.
I also have band-artwork but that aint gonna tell you (yet) :)
Hi good job on the script. I would like to adapt it so I can do something useful with the data. Can you point me in the right direction of how to make it $_POST able?