2009-12-11 29 views
15

我需要一個RSS飼料生成器;我應該使用課程還是應該自己生成飼料?PHP的體面的RSS飼料生成器

如果我自己生成它,哪裏可以獲得全面的標準規範?

如果不是,那麼有沒有什麼好的課程可以做到,並且快速做到並做得好?

+0

我剛剛創建了一個RSS作家類是一個簡單的地圖rss規範:https://github.com/lingtalfi/RssUtil/tree/master/RssWriter – ling 2015-10-25 06:02:36

回答

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:設置圖像添加圖像標籤的源代碼,但標題和鏈接沒有添加到圖像標籤..緊急請回復.. – 2013-01-28 06:47:41

+0

public function setImage($ title,$ link,$ url) – 2013-02-06 12:18:36

+0

它沒有設置鏈接..它只顯示沒有鏈接的圖像 – 2013-02-06 12:20:39

2

這個頁面有一個體面的發電機會議1.0/2.0/ATOM規範,這樣你既可以用它(PHP5)或者只是得到所需要的總體思路:

Php FeedWriter

的使用說明在底部相當詳細,你甚至不需要下載查看源代碼。

+0

嗨cballou,你的鏈接不工作... – 2009-12-11 13:46:23

+0

@Antony - 修復了鏈接。不知道早些時候發生了什麼,但我剛剛醒來:) – 2009-12-11 14:32:06

+0

設置圖像添加源圖像標記,但標題和鏈接沒有添加到圖像標記..緊急請回復.. – 2013-01-28 06:49:30

4

很快會有一個名爲Zend_Feed_Writer的組件Zend Framework,看起來很有趣。以下是該組件(可能是?)的開發者PadráicBrady(link to the blog post)的摘錄摘錄。他說,這是目前在Zend框架孵化器,但第一個正式版本應該在本週末結束準備:

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現在確實存在:http://framework.zend.com/manual/en/zend.feed.writer.html – feeela 2011-10-21 10:52:48

+0

設置圖像添加圖像標籤的源代碼,但標題和鏈接不會添加到圖像標籤..緊急請回復很快.. – 2013-01-28 06:49:08