So I wrote my PHP script, but I want to display the data it echoes externally. How would I go about doing this in maybe, javascript? I tried an iframe but it wasn't working properly.
My script is here:
<?php
$uname = "USERNAME";
$key = "API KEY";
$json = file_get_contents("http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks=" . $uname . "&api_key=" . $key . "&format=json"); // Gets your data
if (strpos($json, 'nowplaying') !== false) {
list($currentsonginfo, $crap) = explode('{"nowplaying":"true"}}', $json);
list($crap, $v2) = explode('{"recenttracks":{"track":[{"artist":{"#text":"', $currentsonginfo);
list($artist, $restinfo) = explode('","', $v2);
list($crap, $currenttrack) = explode('"name":"', $restinfo); }
$playing = $artist . ' - ' . $currentrack; // Checks if a song is playing
if ($playing == ' - ') {
echo '<a href="http://last.fm/user/' . $uname . '/">';
echo "I'm not listening to anything."; // Only if you're not scrobbling
echo "</a>";
} else {
echo '<marquee>';
echo '<a href="http://last.fm/user/' . $uname . '/">';
echo "I'm currently listening to " . $currenttrack . " by " . $artist; // It shows when you're playing music!
echo "</a>";
echo '</marquee>';
}
?>
include()
in PHP wouldn't work because I'd like to use this on external sites that don't support PHP, like Tumblr, etc.
Is there any way I can get the data printed to show up externally?