如何在核心PHP上显示显示来自第三方网站的RSS提要的要求

How can I display a requirement to show an RSS feed from a third party site on core PHP?

本文关键字:显示 网站 第三方 RSS 核心 PHP      更新时间:2023-09-26

如何在PHP核心网站自动发布中显示每日新闻更新?Core php网站在页面上显示RSS提要

我有一个要求显示来自第三方网站的RSS提要。我不想通过浏览器的RSS机制来做到这一点。相反,我想将提要(带有样式)嵌入到特定的页面中。

我的问题是,这可以只使用CMS管理员完成吗?是否有我可以使用的特定内容类型/部分?还是必须通过程序来完成?

我意识到我可以下载一些模块,但我看不到对我正在使用的RSS提要的支持。我试过的是以后的版本。

http://www.cnplus.co.uk/XmlServers/navsectionRSS.aspx?navsectioncode=12911

http://www.anglianwater.co.uk/_assets/media/xml/rss-news.xml

如果您使用的是WOrdpress CMS工具,那么将RSS提要集成到您的页面上会很容易。

签出https://wordpress.org/plugins/tags/rss-feed用于插件。我个人推荐https://wordpress.org/plugins/wp-rss-aggregator/插件,因为这是我遇到的最好的RSS插件之一。

有两种方法可以做到这一点:

  1. 仅使用Javascript在HTML文档中加载第三方提要的内容。这意味着你不会"存储"或"缓存"来自服务器的内容。。。但您将从第三方网站/应用程序加载内容
  2. 将RSS提要的内容存储在后端,并使用PHP将其与其他HTML文档一样加载。在前端,RSS提要中的内容将与其他内容完全相同

这篇博客文章展示了如何使用Superfeeder API的任何一种方法。

$mypix=simplexml_load_file('http://www.anglianwater.co.uk/_assets/media/xml/rss-news.xml');

$i=0;foreach($mypix->频道->项目为$pixinfo)

{
    $title=$pixinfo->title;
    $link=$pixinfo->link;
    $description=$pixinfo->description;
    $pubdate=$pixinfo->pubDate;
  // $image=str_replace("_b.jpg","_s.jpg",$pixinfo->link[1]['href']);
    $title=strip_tags($title, '<br>');
   $link=htmlspecialchars($link);
     $description=strip_tags($description, '<br>');
     $pubdate=strip_tags($pubdate, '<br>');
    echo '<div class="row">
            <div class="box-sizing" style="border:1px; border-color:blue;">
                <p class="large text-muted">'.$title.'</p>
                <p class="large text-muted">'.$description.'</p>
                <p class="large text-muted">'.$pubdate.'</p>
            </div>
        </div>';
     if (++$i == 3) break;      
} 

将以上代码放入"php代码"

如果你得到

rss xmlns:a10="http://www.w3.org/2005/Atom"version="2.0"

类型xml

chnge$pubdate=$pixinfo->pubdate

指示

$pubdate=$pixinfo->children('http://www.w3.org/2005/Atom')->已更新;