file_get_contents()
解析のためにxmlフィードデータを取得するために使用しています。ただし、画像の URL を使用すると、次のように、画像の URL のプレフィックスとしてベース URL を取得しています:-
http://server.com/http://server2.com/image.png
これが私のコードです:
<? 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 as $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])));
}
?>