php - Rss 提要未在浏览器中显示为提要
问题描述
<?php
include 'classes/db.connect.php';
if (isset($_GET['user'])) {
if($blog->blog_check($_GET['user'])) {
$username = strip_tags($_GET['user']);
} else {
http_response_code(404); include('html/blogs/404.html'); die;
}
} else {
http_response_code(404); include('html/blogs/404.html'); die;
}
$current_page = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$url = $blog->get_blogger_branding($username, 'gravurl');
$img = 'assets/blogs/images/'.$_GET['user'].'.png';
file_put_contents($img, file_get_contents($url));
$fbimg = 'https://afpayday.com/assets/blogs/images/'.$_GET['user'].'.png';
header('Content-Type: application/rss+xml');
echo '<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>'.ucfirst($blog->get_blogger_branding($username, "fname")).'\'s Payday Blog</title>
<description>Learn about affiliate marketing and affiliate product reviews.</description>
<link>https://afpayday.com/'.$username.'</link>
<copyright>Copyright 2020 Affiliate Payday</copyright>
<language>en-us</language>
<managingEditor>admin@afpayday.com (Bruce Bates)</managingEditor>
<pubDate>Sun, 23 Feb 2020 09:50:44 -0700</pubDate>
<webMaster>admin@afpayday.com (Bruce Bates)</webMaster>
<atom:link href="https://afpayday.com/'.$username.'/rss/" rel="self" type="application/rss+xml" />
<image>
<url>'.$fbimg.'</url>
<title>'.ucfirst($blog->get_blogger_branding($username, "fname")).'\'s Payday Blog</title>
<link>https://afpayday.com/'.$username.'</link>
<description>'.ucfirst($blog->get_blogger_branding($username, "fname")).'\'s Photo</description>
<width>144</width>
<height>144</height>
</image>
<item>
<title>Test</title>
<guid>https://afpayday.com/'.$username.'</guid>
</item>
</channel>
</rss>
';
?>
根据 w3 验证器,我的提要已正确编码。https://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Fafpayday.com%2Fviraladmin%2Frss%2F
但是浏览器并没有像我期望的那样对待它。
Firefox 尝试将提要下载为文件。
Chrome、Opera 和 Edge 将提要显示为代码,而不是将其显示为文档树,这是我在查看 RSS 提要时通常看到的。
只有 Internet Explorer 似乎可以正确处理它并显示“您想订阅此提要”选项。
提要在这里:https ://afpayday.com/viraladmin/rss/
我希望它在浏览器中看起来更像https://www.feedforall.com/sample.xml
我究竟做错了什么?
解决方案
推荐阅读
- spring-boot - 如何使用 Nginx 位置为在不同端口上运行的两个后端应用程序提供服务?
- reactjs - React hook state - 如何在显示对话框后将其转换为初始状态
- reactjs - 如何修复错误 React-Redux:动作必须是普通对象。使用自定义中间件进行异步操作?我需要同样的澄清
- c# - 从服务器(本地主机)获取 HTTP 响应
- javascript - 在主函数范围javascript内访问ajax调用中的变量
- rust - rust 中的裸机自旋锁实现
- python - 这是什么颜色图?
- javascript - 将 javstvalidate 和 phpmailer 与数据库一起使用
- c# - WPF 中带有索引器的 DisplayMemberPath
- python - Python Selenium - 网站行为不同