このようなものを投稿しましたが、応答はありませんでしたが、十分なデータを提供しなかったためです。私はそれを閉じて、よりよく説明しているのでこれを作りました. これを作るつもりはありませんでした。
私のコード:
<?php
$q = $_GET['q'];
$xml = simplexml_load_file("http://ws.spotify.com/search/1/track?q=".$q."");
echo $xml->tracks . "<br />";
$num = 0;
foreach($xml->children() as $child){
$num ++;
if($num < 5){
echo "<a href='".$child->attributes(href)."' title=''>".$child->name . " by " . $child->artist->name . "</a><br />";
}
}
?>
トラックの「href」の属性を呼び出そうとしています。
Spotify の Web サイトでは、次のように表示されます。
<?xml version="1.0" encoding="utf-8"?>
<tracks xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.spotify.com/ns/music/1">
<opensearch:Query role="request" startPage="1" searchTerms="foo"/>
<opensearch:totalResults>768</opensearch:totalResults>
<opensearch:startIndex>0</opensearch:startIndex>
<opensearch:itemsPerPage>100</opensearch:itemsPerPage>
<track href="spotify:track:3ZsjgLDSvusBgxGWrTAVto">
<name>The Pretender</name>
<artist href="spotify:artist:7jy3rLJdDQY21OgRLCZ9sD">
<name>Foo Fighters</name>
</artist>
<id type="isrc">USRW30700007</id>
<id type="isrc">USRW30700007</id>
<track-number>1</track-number>
<length>269.373000</length>
<popularity>0.79251</popularity>
</track>
...
</tracks>