I created php code that gets a rest xml response. The code follows:
<table valign="top" cellpadding="10" style=" padding:0px 15px;"><tr></tr><tr>
<?php $song = str_replace(' ', '+', $post['title']);
$url = "http://ift.tt/1oDAKhD";
$xml=simplexml_load_file("$url");
foreach($xml->tracks->track as $track){
foreach($track->name as $name) {
$image = $track->image;
$link = str_replace(' ', '-', $name);
echo "<th width='20%' valign='top'><img src='$image' alt='$name' height='90' width='90'></br></br><a href='http://ift.tt/1sLisww'>$name</a></th>";
}
}
?>
</tr>
</table>
It retrieves xml such as the following:
<lfm status="ok">
<tracks page="1" perPage="5" totalPages="200" total="1000">
<track><name>Chandelier</name><duration>216</duration><playcount>109163</playcount><listeners>38691</listeners><mbid>4d507ca4-0d95-494c-b97b-e2fa50c926c1</mbid><url>http://ift.tt/Vt7sp2 fulltrack="0">0</streamable><artist><name>Sia</name><mbid>2f548675-008d-4332-876c-108b0c7ab9c5</mbid><url>http://ift.tt/YgUMTW size="small">http://ift.tt/Vt7sp6 size="medium">http://ift.tt/YgUKLX size="large">http://ift.tt/YgUKLZ size="extralarge">http://ift.tt/Vuldn9;
<track><name>Do I Wanna Know?</name><duration>273</duration><playcount>64234</playcount><listeners>33378</listeners><mbid>575d24ee-cf80-48ad-beeb-9295c7d05b35</mbid><url>http://ift.tt/YgUMU1 fulltrack="0">0</streamable><artist><name>Arctic Monkeys</name><mbid>ada7a83c-e3e1-40f1-93f9-3e73dbc9298a</mbid><url>http://ift.tt/Vt7spc size="small">http://ift.tt/YgUKM1 size="medium">http://ift.tt/Vt7spe size="large">http://ift.tt/YgUL2h size="extralarge">http://ift.tt/1oDAKxT;
<track><name>A Sky Full of Stars</name><duration>268</duration><playcount>60604</playcount><listeners>30131</listeners><mbid>d0d9e6e7-47c1-4470-9124-d10613c09ece</mbid><url>http://ift.tt/YgUMU7 fulltrack="0">0</streamable><artist><name>Coldplay</name><mbid>cc197bad-dc9c-440d-a5b5-d52ba2e14234</mbid><url>http://ift.tt/Vt7sFu size="small">http://ift.tt/YgUL2l size="medium">http://ift.tt/Vt7q0y size="large">http://ift.tt/YgUNao size="extralarge">http://ift.tt/Vulgzg;
<track><name>Stay with Me</name><duration>173</duration><playcount>70310</playcount><listeners>30071</listeners><mbid>c8dbf2c6-cbd2-48d2-ae04-e3098e29e306</mbid><url>http://ift.tt/YgUNas fulltrack="0">0</streamable><artist><name>Sam Smith</name><mbid>5a85c140-dcf9-4dd2-b2c8-aff0471549f3</mbid><url>http://ift.tt/YgUL2q size="small">http://ift.tt/Vt7q0C size="medium">http://ift.tt/YgUNau size="large">http://ift.tt/YgUNaw size="extralarge">http://ift.tt/1oDAKxV;
<track><name>Summer</name><duration>224</duration><playcount>57584</playcount><listeners>29519</listeners><mbid>9947d625-1d29-45df-a988-6e907fd1fea1</mbid><url>http://ift.tt/1oDAKxX fulltrack="0">0</streamable><artist><name>Calvin Harris</name><mbid>8dd98bdc-80ec-4e93-8509-2f46bafc09a7</mbid><url>http://ift.tt/Vt7sFE size="small">http://ift.tt/YgUNaA size="medium">http://ift.tt/Vt7spa size="large">http://ift.tt/YgUL2x size="extralarge">http://ift.tt/Vuldne;
</tracks>
</lfm>
This code when grabbing the image gets the small image. I would like it to grab the large image. How can I easily alter it to do so. Thanks.
No comments:
Post a Comment