1

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])));
}
?>  
4

1 に答える 1

0

不要な引用符を削除してください:

変化する

echo "<img src=\"'$imgsrc'\" alt=\"\" \/>";

echo "<img src=\"$imgsrc\" alt=\"\" \/>";
于 2013-07-23T22:49:36.747 に答える