Retrieving BIO information in LastFM API and PHP -
i'm trying artist bio information lastfm api i'm having trouble.
i'm using php , curl request that's returning result xml.
if use url gets sent curl , load in browser show's desired. however, result returned curl in php script missing properties of xml.
for example: artist->bio->summary there no content.
you can replicate i'm doing ill copy basic concepts here:
open in browser: http://ws.audioscrobbler.com/2.0/artist/cher/info.xml
copy , paste php file , open:
$url = 'http://ws.audioscrobbler.com/2.0/artist/cher/info.xml'; $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_timeout, 20); curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_ssl_verifypeer, false); $retdata = curl_exec($ch); curl_close($ch); echo '<pre>'; echo $retdata; echo '</pre>';
you'll see returned results similar missing content in curl request. i've tried doing simplexml_load_file() same happens. missing? cheers help!
try replace
echo $retdata;
with
echo htmlspecialchars($retdata);
and you'll see there. you're printing raw xml in html context, , of tags in xml interpreted html tags.
Comments
Post a Comment