簡體   English   中英

如何顯示要求在核心PHP上顯示來自第三方站點的RSS feed?

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

如何在核心PHP網站自動發布中顯示每日新聞更新? 核心php網站在頁面上顯示RSS Feed

我需要顯示第三方站點的RSS提要。 我不想通過瀏覽器的RSS機制執行此操作。 相反,我想將提要(帶有樣式)嵌入到特定頁面中。

我的問題是,可以僅使用CMS管理員來完成此操作嗎? 我可以使用特定的內容類型/部分嗎? 還是必須以編程方式完成?

我意識到有一些模塊可以下載,但是我看不到我正在使用的RSS feed的支持。 我嘗試過的用於更高版本。

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

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

如果您使用的是WOrdpress CMS工具,則很容易將RSS feed集成到您的頁面上。

檢出https://wordpress.org/plugins/tags/rss-feed中的插件。 我個人推薦https://wordpress.org/plugins/wp-rss-aggregator/插件,因為這是我遇到過的最好的RSS插件之一。

有兩種方法可以做到這一點:

  1. 僅使用Javascript將第3方供稿的內容加載到HTML文檔中。 這意味着您不會“存儲”或“緩存”服務器中的內容...,而是將從第三方站點/應用程序中加載內容。
  2. 將RSS feed的內容存儲在您的后端,並使用PHP像其他HTML文檔一樣加載它。 到前端,RSS提要中的內容將與其余內容完全一樣。

這篇博客文章展示了如何通過兩種方法使用Superfeedr API

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

$ i = 0; foreach($ mypix-> channel-> item為$ 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”版本=“ 2.0”

輸入xml

chnge $ pubdate = $ pixinfo-> pubDate

裝的

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM