2009-12-11 17 views
15

Necesito un generador de fuentes RSS; ¿Debo usar una clase o debería generar la alimentación yo mismo?Generador de alimentación RSS decente para PHP

Si debería generarlo yo mismo, ¿dónde es un buen lugar para obtener especificaciones exhaustivas de los estándares?

Si no, ¿hay buenas clases para hacerlo y hacerlo rápido y hacerlo bien?

+0

acabo de crear una Clase de Writer de RSS que es una simple especificación de map to rss: https://github.com/lingtalfi/RssUtil/tree/master/RssWriter – ling

Respuesta

19

PHP Universal Feed Generator (supports RSS 1.0, RSS 2.0 and ATOM)

Features:

  • Generates RSS 1.0, RSS 2.0 and ATOM 1.0 feeds
  • All feeds are are validated by feed validator.
  • Supports all possible feed elements.
  • Simple and easy to define channel and feed items
  • Implements appropriate namespaces for different versions.
  • Automatically converts date formats.
  • Generates UUID for ATOM feeds.
  • Enables usage of subtags and attributes. (example: image and encloser tags)
  • Completely Object oriented in PHP5 class structure.
  • Handles CDATA encoding for required tags.
  • Nearly same code for generating all kinds of feed

Examples

+0

@Perter Lind: establece la imagen que agrega la fuente a la etiqueta de la imagen pero el título y el enlace no se agrega a la etiqueta de la imagen ... urgente responde pronto ... –

+0

función pública setImage ($ title, $ link, $ url) –

+0

No está configurando el enlace .. Muestra solo la imagen sin enlace en ese –

2

Esta página tiene una reunión generador decente especificación 1.0/2.0/ATOM por lo que podría o bien utilizarla (PHP5) o simplemente obtener una idea general de lo que se necesita:

Php FeedWriter

Las notas de uso en la parte inferior es bastante detallada y ni siquiera tiene que descargar para ver la fuente.

+0

Hola cballou, tu enlace no funciona ... –

+0

@Antony - corrigió el enlace. no estoy seguro de lo que sucedió antes, pero acababa de despertar :) –

+0

Establecer imagen añadiendo la fuente a la etiqueta de la imagen, pero el título y el enlace no se agrega a la etiqueta de la imagen ... urgente, por favor, responda pronto .. –

4

Pronto habrá un componente para Zend Framework llamado Zend_Feed_Writer que se ve bastante interesante. Aquí hay un extracto de un feed de uno de los desarrolladores (tal vez el?) De ese componente, Padráic Brady (link to the blog post). Dice que es actualmente en el Zend Framework Incubadora, pero que una primera versión oficial debe estar listo para el final del fin de semana:

Zend_Feed_Writer

The new kid on the block, to be added in Zend Framework 1.10, is Zend_Feed_Writer. A bit like the older Zend_Feed_Builder classes, its purpose is to generate Atom 1.0 and RSS 2.0 feeds. The difference is that, like its sibling Zend_Feed_Reader, it is standards aware and operates entirely using PHP's DOM.

Why another feed generation component? The problem is somewhat similar to the one that Zend_Feed_Reader solved. Generating an RSS and Atom feed is far more involved than sticking a bunch of elements together - each standard has its quirks, its unique features, and its own set of best practices outside of the standards. Using Zend_Feed_Builder, you relied on two things - repetition and validation. Moving away from its core focus required more work, even to the extent of subclassing, and you were always at the mercy of misinterpreting a standard.

Zend_Feed_Writer builds on the simple API of Zend_Feed_Reader (using setters rather than getters) and the concept of having the component understand the standards (so you don't have to). The component is split across two class types - a base data container to store feed data and ensure it conforms to expected formats, and a renderer to actually generate the feeds and provide feedback on standards adherence. For example, in Atom 1.0 the omission of a title will generate an exception - a title is an obligatory element under the Atom 1.0 standard. While this could be interpreted as a nuisance, the fact is that an invalid Atom 1.0 feed is worse than useless. Better you are irritated now, than later when an online validator calls you rude names :-).

The net result of this approach is that you focus on the data, and let Zend_Feed_Writer worry about what elements and attributes to use. It should, in theory (always a grand thing), be impossible for Zend_Feed_Writer to produce an invalid feed.

Of course, we also throw in the concept of Extensions, as with Zend_Feed_Reader, allowing you to add support for RSS and Atom extensions more dynamically without the need for subclassing or API arm twisting.

If you go looking for Zend_Feed_Writer, it's currently in chunks in the Incubator. I should have it entirely integrated and functional over the weekend. You can however give it a shot for writing Atom 1.0 feeds so long as you stick to the core elements (i.e. most blog feeds). RSS 2.0 support is the last piece I need to complete in full.

+0

Zend_Feed_Writer ya existe: http://framework.zend.com/manual/en/zend.feed.writer.html – feeela

+0

Establecer imagen que agrega la fuente a la etiqueta de la imagen pero el título y el enlace no se agrega a la etiqueta de la imagen .. urgente por favor responde pronto .. –

Cuestiones relacionadas