Skip to content

Instantly share code, notes, and snippets.

@ormanya
ormanya / lastfm.php
Last active August 30, 2018 23:20 — forked from dewey/lastfm.php
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
View lastfm.php
#!/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