Question

Je l'ai découvert il y a une aide pour aider à l'analyse des flux RSS sur le cadre Kohana.

Y at-il un pour aider à créer un?

Était-ce utile?

Autres conseils

Whip it avec la méthode create() de la classe Feed dans Kohana 3. Vous trouverez le code de celui-ci à l'adresse suivante:

  

système / classes / kohana / feed.php

Vous devez href="http://www.kerkness.ca/kowiki/doku.php?id=working_with_atom_and_rss_feeds" définissent les informations de canal et de ses éléments de flux en tant que minimum.

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

brancher ensuite ces données dans le procédé pour générer le XML:

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

Ce qui vous donnera quand vous echo dehors ou passez à la vue pertinente:

<?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>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top