我正在尝试从博客设置实时Feed,但内容不会显示。有任何想法吗?该博客基于WP,我将下面的内容设置为php文件。 php文件包含另一个物理博客源的卷曲。
<?php
try{
// Get RSS feed
$blog_feed = @file_get_contents_curl('http://www.coordsport.com/csblogfeed.php');
if ($blog_feed){
// Convert to traversable XML object
$blog_posts = new SimpleXMLElement($blog_feed);
// Set limits and counter
$list_count = 5;
$current_item = 0;
// Loop through each feed item
foreach ($blog_posts->channel->item as $blog_post)
{
// Increment counter and check count
if (++$current_item > $list_count) break;
// Force data type for description
$post_description = (string)$blog_post->description;
$desc_xml = new SimpleXMLElement('<div>' . $post_description . '</div>');
// Reset thumbnail
$thumbnail_src = '';
if (@$desc_xml->img[0])
{
$thumbnail_src = (string) $desc_xml->img[0]->attributes()->src;
}
}
else
{
echo 'Error Loading Feed';
}
}
catch(Exception $e)
{
echo 'Error Loading Feed.<br /><br /><div style="font-size:75%;color:#ccc;">' . htmlspecialchars($e) . '</div>';
}
?>
file_get_contents_curl csblogfeed.php包含,博客工作正常并在以下网址中正确显示。
<?php
echo file_get_contents('http://www.coordsport.com/blog/feed/');
?>