Embutido método Kohana para auxiliar com o desenvolvimento de uma alimentação de RSS

StackOverflow https://stackoverflow.com/questions/937921

  •  06-09-2019
  •  | 
  •  

Pergunta

Eu descobri há um ajudante para auxiliar na análise de feeds RSS sobre o quadro Kohana.

Existe um para ajudar a criar um?

Outras dicas

Chicote-lo com o método create() da classe Feed em Kohana 3. Você vai encontrar o código dele no seguinte:

sistema / aulas / kohana / feed.php

Você precisará definir as informações do canal e seus itens de alimentação como um mínimo.

$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
         ); 

Em seguida, conecte esses dados para o método para gerar o XML:

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

que lhe dará isso quando você echo-lo ou passá-lo para o ponto de vista relevante:

<?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>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top