Create an RSS or Atom feed

There are at least three ways to go about creating an RSS, Atom, or other XML feed.

1) Catalyst::View::XML::Feed

Catalyst::View::XML::Feed lets you simply put feed data into the stash $c->stash->{feed} = $some_feed_data; and it takes care of the rest.code

Your feed data can be an XML::Feed, XML::RSS, XML::Atom::SimpleFeed, XML::Atom::Feed, XML::Atom::Syndication::Feed, or even your own custom objects. You can also use plain Perl hashrefs.

Look at the Catalyst::View::XML::Feed documentation for more details.

2) Render with an XML::* feed object

Create an object representing your feed, using one of the common XML::* modules listed above.

In your controller you now generate XML with your feed object, and set the response body. If, for example, you have an XML::Feed object you might do this: $c->res->body($feed->as_xml);

You will also need to ensure you send the correct Content-Type headers: $c->res->content_type('application/rss+xml'); or $c->res->content_type('application/atom+xml'); or $c->res->content_type('text/xml');

For more details and an example, see Catalyst::Manual::Cookbook.

3) Do everything manually with a template

This is the most difficult, and most error-prone way to go about serving RSS or Atom feeds. If you absolutely must, though, see the example in Catalyst::Manual::Cookbook

My tags:
 
Popular tags:
 
Powered by Catalyst
Powered by MojoMojo Hosted by Shadowcat - Managed by Nordaaker