PHP and Last.fm API
Please can someone point me in the right direction. I had this working
before but it's been a while since I played with PHP.
So I have a JSON structure such as
http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=Cher&api_key=63692beaaf8ba794a541bca291234cd3&format=json
and I'd like to pick out various bits of information such as similar
artists (names and images), tags, the extralarge image, content etc
I got the similar arists working by using
<?php
$url =
'http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=Queens%20Of%20the%20STone%20Age&api_key=XXX&format=json';
$content = file_get_contents($url);
$json = json_decode($content, true);
foreach($json['artist']['similar']['artist'] as $item) {
print $item['name'];
print '<br>';
}
?>
How do I extract the "large" image however from the following:
"artist": [{
"name": "Them Crooked Vultures",
"url": "http:\/\/www.last.fm\/music\/Them+Crooked+Vultures",
"image": [{
"#text":
"http:\/\/userserve-ak.last.fm\/serve\/34\/38985285.jpg",
"size": "small"
}, {
"#text":
"http:\/\/userserve-ak.last.fm\/serve\/64\/38985285.jpg",
"size": "medium"
}, {
"#text":
"http:\/\/userserve-ak.last.fm\/serve\/126\/38985285.jpg",
"size": "large"
}]
Thanks,
JJ
No comments:
Post a Comment