我发现有个帮手RSS的解析,以帮助在Kohana的框架饲料。

有一个帮助建立一个?

有帮助吗?

其他提示

create()类的Feed方法的Kohana 3.您将在下面找到它的代码掀起起来:

  

系统/类/ Kohana的/ feed.php

您需要定义rel="nofollow" title="Working信道信息和其馈电的项目,如最小

$info = array(
           'title' => 'Dark into the Narwhal',
           'pubDate' => date("D, d M Y H:i:s T"),
           'description' => 'Eating bacon, taking names and leaving fortunes',
           'link' => 'http://example.com/',
           'copyright' => 'The Narwhal Peon',
           'language' => 'en-us',
           'ttl' => '7200',
        );

$items = array(
           array(
               'title' => 'We journey with watermelon helmets',
               'link' => 'blog/journey-with-watermelon-helmets',
               'description' => 'Dawn breaks and the wind follows soon after. 
                                 We have found our supplies run low.',
           ),

            //-- and the other posts you want to include
         ); 

然后该数据插入方法来生成XML:

$xml = Feed::create($info, $items);

这将给你这个当你echo它或把它传递给相关的观点:

<?xml version="1.0" encoding="UTF-8"?>
 <rss version="2.0">
  <channel>
  <title>Dark into the Narwhal</title>
  <pubDate>Fri, 21 Dec 2012 13:32:42 EST</pubDate>
  <description>Eating bacon, taking names and leaving fortunes</description>
  <link>http://example.com/</link>
  <copyright>The Narwhal Peon</copyright>
  <language>en-us</language>
  <ttl>7200</ttl>
  <generator>KohanaPHP</generator>
  <item>
    <title>We journey with watermelon helmets</title>
    <link>http://example.com/blog/journey-with-watermelon-helmets</link>
    <description>Dawn breaks and the wind follows soon after. 
                 We have found our supplies run low.</description>
  </item>

  <!-- the other posts will be here -->

  </channel>
</rss>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top