-
-
Save ViralTaco/5dc04877aedceb7fd30912519e1cca6e to your computer and use it in GitHub Desktop.
Last.fm "now playing" script for Textual.Installation: Copy this script to ~/Library/Application Scripts/com.codeux.irc.textual/lastfm.php Usage:/lastfm
This file contains hidden or 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 | |
<? | |
# get api key here: https://www.last.fm/api/account/create | |
$api_key = "API_KEY_HERE"; | |
$user = "HANDLE_HERE"; # case sensitive | |
$method = "method=user.getrecenttracks&user="; | |
$path = "http://ws.audioscrobbler.com/2.0/?"; | |
$key = "&api_key=".$api_key; | |
$doc = new DOMDocument; | |
$doc->load($path.$method.$user.$key); | |
$node = $doc->getElementsByTagName('track')[0]; | |
$track = [ | |
'artist' => $node->getElementsByTagName('artist')[0]->nodeValue | |
, 'name' => $node->getElementsByTagName('name')[0]->nodeValue | |
]; | |
echo "/me is listening to '" | |
.$track['name']."' by '" | |
.$track['artist']."'." | |
; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment