RSS feeds are a form of web services, as they provide a service, over the web, using a known format to expose data. Due to their simplicity, they are a great way to introduce us to the world of web services, particularly as CakePHP offers a built in method to create them.
In the recipe Consuming RSS feeds with a datasource from Chapter 5, Datasources, we learned how to fetch content from a foreign RSS feed. In this recipe, will do exactly the opposite: produce a feed for our site that can be used by other applications.
To go through this recipe we need a sample table to work with. Create a table named posts
, using the following SQL statement:
CREATE TABLE `posts`(posts `id` INT NOT NULL AUTO_INCREMENT, `title` VARCHAR(255) NOT NULL, `body` TEXT NOT NULL, `created` DATETIME NOT NULL, `modified` DATETIME NOT NULL, PRIMARY KEY(`id`) );
Add some sample data, using the following SQL statements:
INSERT INTO `posts`(`title`,posts `body`, `created`, `modified`)...