如何在核心PHP上显示从第三方站点显示RSS源的要求?

时间:2015-12-05 06:05:53

标签: javascript php rss

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

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

我的问题是,这可以使用CMS管理员来完成吗?我可以使用特定的内容类型/部分吗?或者这是否必须以编程方式完成?

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

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

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

3 个答案:

答案 0 :(得分:1)

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

结帐https://wordpress.org/plugins/tags/rss-feed了解插件。我个人推荐https://wordpress.org/plugins/wp-rss-aggregator/插件,因为这是我遇到过的最好的RSS插件之一。

答案 1 :(得分:0)

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

  1. 仅使用Javascript在HTML文档中加载第三方Feed的内容。这意味着你不会"存储"或者"缓存"来自您服务器的内容......但您将从第三方网站/应用程序加载内容。
  2. 将RSS源的内容存储在后端,并使用PHP将其加载为其余HTML文档。对于前端,RSS源中的内容将与您内容的其他内容完全相同。
  3. 此博客文章介绍了如何将Superfeedr API与任何一种方法结合使用。

答案 2 :(得分:0)

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

$ I = 0; foreach($ mypix-> channel-> item as $ 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;      

} 

将上面的代码放在&#34; php代码&#34;

如果你得到

rss xmlns:a10 =&#34; http://www.w3.org/2005/Atom"版本=&#34; 2.0&#34;

输入xml

chnge $ pubdate = $ pixinfo-&gt; pubDate

insted of

$ pubdate的= $ pixinfo-&GT;儿童(&#39; http://www.w3.org/2005/Atom&#39;) - &GT;更新;