-
-
Save ormanya/d0f21880ec015a807b9187c48e6715b8 to your computer and use it in GitHub Desktop.
Last.fm "now playing" script for Textual. Installation: Replace 'ormanya' with your Last.fm username and 'apikey' with your last.fm api key. Copy this script to ~/Library/Application Scripts/com.codeux.apps.textual/lastfm.php Usage:/lastfm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
$doc = new DOMDocument(); | |
$doc->load("http://ws.audioscrobbler.com/2.0/?api_key=apikey0&method=user.getRecentTracks&limit=1&user=ormanya&limit=1&format=xml"); | |
$arrFeeds = array(); | |
foreach ($doc->getElementsByTagName('track') as $node) { | |
$itemRSS = array ( | |
'artist' => $node->getElementsByTagName('artist')->item(0)->nodeValue, | |
'name' => $node->getElementsByTagName('name')->item(0)->nodeValue | |
); | |
array_push($arrFeeds, $itemRSS); | |
} | |
echo ("/me is listening to ".$arrFeeds[0]['name']." by ".$arrFeeds[0]['artist']."."); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment