这个问题是这个问题的后续问题:使用 google chrome 查看 rss feed
我从此页面复制了源代码(希望这对网站所有者来说没问题):
http://www.petefreitag.com/rss/.
我转义了所有引号并用它制作了一个 php 文件。该文件如下所示:
<?php
header('Content-Type: application/rss+xml');
echo "<?xml version=\"1.0\" ?>
<?xml-stylesheet type=\"text/css\" href=\"http://www.petefreitag.com/rss/simple_style.css\" ?>
<rss version=\"2.0\">
<channel>
<title>Pete Freitag's Homepage</title>
<link>http://www.petefreitag.com/</link>
<description>Covering ColdFusion, Java, Web Development, and other topics</description>
<language>en-us</language>
<lastBuildDate>Fri, 23 Mar 2012 18:57:00 GMT</lastBuildDate>
<ttl>45</ttl>
<item>
REST OF THE SOURCE CODE
</rss>
";
?>
在这里您可以看到结果:http://web.student.tuwien.ac.at/~e0250890/rsstest/test.php
然而,关于http://www.petefreitag.com/rss/chrome 将页面视为 rss feed,在我的示例中它仅显示源代码。
有什么区别以及如何强制 chrome 以 rss feed 方式查看页面?
尝试将标题更改为application/xml
这通过更改标题对我有用:
<?php
header('Content-Type: application/xml');
echo file_get_contents('http://web.student.tuwien.ac.at/~e0250890/rsstest/test.php');
?>
Mozilla 接受整个范围的标头
text/xml
,application/xml
,application/rss+xml
,application/atom+xml
但 chrome 似乎只接受text/xml
or application/xml
不是 100% 确定为什么,也许你应该通过 google 来解决;p
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)