コードに少し問題があります。Spotify から曲 ID を取得しようとしています。これは私にとっては問題なく機能しますが、URL に特殊文字 (ü、ö、ä など) を使用するとうまくいきません。
この警告が表示されます (最初の行はエコーされた URL です):
http://ws.spotify.com/search/1/track?q=Sportfreunde+Stiller+AND+track:Frühling
Warning: SimpleXMLElement::__toString() [simplexmlelement.--tostring]: Node no longer exists in /Applications/AMPPS/www/spotify.php on line 28
これは私のコードです:
function getID($artist,$title){
$url = utf8_decode("http://ws.spotify.com/search/1/track?q=".$artist."+AND+track:".$title);
echo $url;
$xml = simplexml_load_file($url);
$id= $xml->track->attributes();
return($id);
}
echo getID("Sportfreunde+Stiller","Frühling");
これを解決する方法は?utf_encode() を試しましたが、うまくいきませんでした。
ありがとうございました!