php - Issue with URL data returned by get_file_contents used on XML feed -
i using file_get_contents()
retrieve xml feed data, parsing. image url's however, getting base url prefixing image url - this:-
http://server.com/http://server2.com/image.png
here's code:
<? php $context = stream_context_create( array( 'http' => array( 'follow_location' => false ) ) ); $content =file_get_contents("http://xyogasangeetax.api.channel.livestream.com/2.0/latestclips.xml", false, $context); $data = new simplexmlelement($content); foreach($data->channel->item $entry) { if ($media = $entry->children('media', true)) { $attributes = $media->content->attributes(); $src = $play_attributes['url']; if ($media->thumbnail) { $attributes = $media->thumbnail->attributes(); $imgsrc = (string)$attributes['url']; echo "<img src=\"'$imgsrc'\" alt=\"\" \/>"; } } $pub_date= explode("-",$entry->pubdate); echo date('f d,y',strtotime(trim($pub_date[0]))); } ?>
please delete unneeded quotes:
change
echo "<img src=\"'$imgsrc'\" alt=\"\" \/>";
to
echo "<img src=\"$imgsrc\" alt=\"\" \/>";
Comments
Post a Comment