kohana架構產生feed,kohana架構feed

來源:互聯網
上載者:User

kohana架構產生feed,kohana架構feed
建立Feed
Feed::create()方法用給定的參數來建立 RSS戒者 Atom feed。下面是可接受的參數。
■  info:你 feed 中的 header 詳紳資訊的數組,如 pubDate 和 description
■  items:一個填滿了你 feed 項目的數組
■  format:你的 feed 的格式,預設是 rss2

■  encoding:你的 feed 使用的編碼,預設是 UTF-8

效果


下面癿例子從一個部落格資料例子的數組建立一個 feed

        $info = array(            'title' => 'My Feed Title',            'pubDate' => date("D, d M Y H:i:s T"),            'description' => 'My recent blog posts',        );        $items = array(            array(                'title' => 'My Post Title',                'link' => 'blog/post/45',                'description' => 'This is the content summary of my post',            ),                array(                'title' => 'Another Post Title',                'link' => 'blog/post/46',                'description' => 'This is the content summary of my post',            ),            array(                'title' => 'Yet Another Post Title',                'link' => 'blog/post/47',                'description' => 'This is the content summary of my post',            ),        );        $xml = Feed::create($info, $items);        print_r($xml); die;

這個將產生下列癿 XML
<?xml version="1.0" encoding="UTF-8"?>    <rss version="2.0">      <channel>        <pubDate>Fri, 11 Dec 2009 15:57:51 CST</pubDate>        <description>My recent blog posts</description>        <title>My Feed Title</title>        <link>http://www.example.com/</link>        <generator>KohanaPHP</generator>        <item>          <title>My Post Title</title>          <link>http://gallery.artmoi.com/blog/post/45</link>          <description>This is the content summary of my post</description>        </item>        <item>          <title>Another Post Title</title>          <link>http://gallery.artmoi.com/blog/post/46</link>          <description>This is the content summary of my post</description>        </item>        <item>          <title>Yet Another Post Title</title>          <link>http://gallery.artmoi.com/blog/post/47</link>          <description>This is the content summary of my post</description>        </item>      </channel>    </rss> 


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.