XML : Open image of the singer by LastFM and function (artist.getinfo)

Good, I have this code of LastFM API <?php $xml = simplexml_load_file("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=ARIANA GRANDE&api_key=b25b959554ed76058ac220b7b2e0a026"); $largeImage = $xml->xpath('/lfm/artist/image[@size="mega"]')[0]; echo '<img src="'.$largeImage.'" />

it appears used the image of Ariana Grande.

Now the link of my XML file is :http://radiojoven.6te.net/playlist.xml

Well, what I am trying to do is change "ARIANA GRANDE" (the artist's name) in the link of the "simplexml_load_file" (in the php code) with the info that my XML file provides. I tried to make a code like this but to no avail.

  <?php  $xml = simplexml_load_file('http://radiojoven.6te.net/playlist.xml');  $artist = urlencode($xml->Event->Song->Artist['name'];);   $url = simplexml_load_file("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist='.$artist.'&api_key=50ac27433c63f7298064f434f4ef6d15);  $xml2 = @simplexml_load_file($url);  $largeImage = $xml2->xpath('/lfm/artist/image[@size="mega"]')[0];  echo '<img src="'.$largeImage.'" />';       ?>    

Can you please help me doing this?

Thank you all in advance.

No comments:

Post a Comment