NowPlay for ume@c.j.r

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
header('Content-Type:text/html;charset=utf-8');
$lastfmNowPlay = json_decode(
file_get_contents('http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=alex_popov&api_key=&limit=1&format=json'));
function Html($title)
{
echo("<!doctype html>\n<html lang=\"en\">\n<head>
<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">");
echo(" <title>${title}</title>\n</head>");
echo("<body></body>\n</html>\n");
}
if (count($lastfmNowPlay->recenttracks->track) == 2)
{
// echo($lastfmNowPlay->recenttracks->track[0]->{"@attr"}->nowplaying);
$artist = $lastfmNowPlay->recenttracks->track[0]->artist->{'#text'};
$song = $lastfmNowPlay->recenttracks->track[0]->name;
Html("IIIypuk слушает «${artist}${song}»");
}
else
Html('IIIypuk последний раз слушал в '.
$lastfmNowPlay->recenttracks->track->date->uts);