所以我刚刚为我的网站制作了一个RSS订阅源,假设在RSS订阅源中的图像根本没有显示。它的所有显示都是标题和文件名。有没有办法让我添加一些额外的代码来抓取图像并将图像放在rss feed中。
btw这一部分 - $ description = $ dataBlogDisplay ['pic'];假设得到图片但显示的只是文件名。
这是我的代码
<?php
define ("DB_HOST", "xxx"); // set database host
define ("DB_USER", "xxx"); // set database user
define ("DB_PASS","xxxx"); // set database password
define ("DB_NAME","xxxx"); // set database name
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die("Couldn't make connection.");
$db = mysql_select_db(DB_NAME, $link) or die("Couldn't select database");
$query = "select story, url, pic from `posts` limit 20";
$getBlogDisplay = mysql_query($query);
header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='UTF-8'?>
<rss version='2.0'>
<channel>
<title></title>
<link></link>
<description></description>
<language>en-us</language>";
while($dataBlogDisplay = mysql_fetch_array($getBlogDisplay)){
$title = $dataBlogDisplay['story'];
$link = $dataBlogDisplay['url'];
$description = $dataBlogDisplay['pic'];
echo "<item>
<title>$title</title>
<link><![CDATA[http://www.xxxxxx.com/post/$description]]></link>
<description>$description</description>
</item>";
}
echo "</channel></rss>";
?>
答案 0 :(得分:-1)
图片应放在此
中 <image>
<url>http://www.w3schools.com/images/logo.gif</url>
<title>W3Schools.com</title>
<link>http://www.w3schools.com</link>
</image>