spe*_*ndo 3 php xml rss google-chrome
这个问题是这个问题的后续: 让谷歌浏览器查看一个RSS提要
我从这个页面复制了源代码(希望这对网站所有者没问题):
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>
";
?>
Run Code Online (Sandbox Code Playgroud)
在这里你可以看到结果:http : //web.student.tuwien.ac.at/~e0250890/rsstest/test.php
但是,在http://www.petefreitag.com/rss/ 上, chrome 将页面视为 rss 提要,在我的示例中,它仅显示源代码。
有什么区别,如何强制 chrome 将页面作为 rss 提要查看?
尝试将标题更改为 application/xml
这通过更改标题对我有用:
<?php
header('Content-Type: application/xml');
echo file_get_contents('http://web.student.tuwien.ac.at/~e0250890/rsstest/test.php');
?>
Run Code Online (Sandbox Code Playgroud)
Mozilla 接受各种标题
text/xml, application/xml, application/rss+xml,application/atom+xml
但似乎 chrome 只接受text/xml或application/xml
不是 100% 确定为什么,也许你应该用谷歌来解决它;p
| 归档时间: |
|
| 查看次数: |
4681 次 |
| 最近记录: |