I have a JSON structure such as http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=Cher&api_key=XXXX&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>';
}
?>
However, how do I extract the "large" image 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
ALL SORTED! Finished product: http://www.strictlyrandl.com/artist/queens-of-the-stone-age/
You'll need to loop through the images and print it:
To print them only if they're of size large or extra large, you can use a simple
if
statement: