PHP Universal Feed Generator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.4 KiB

11 years ago
11 years ago
  1. <?php
  2. // You should use an autoloader instead of including the files directly.
  3. // This is done here only to make the examples work out of the box.
  4. include('../Item.php');
  5. include('../Feed.php');
  6. include('../RSS2.php');
  7. date_default_timezone_set('UTC');
  8. use \FeedWriter\View\RSS2;
  9. /*
  10. * Copyright (C) 2008 Anis uddin Ahmad <anisniit@gmail.com>
  11. *
  12. * This file is part of the "Universal Feed Writer" project.
  13. *
  14. * This program is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation, either version 3 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  26. */
  27. //Creating an instance of RSS2 class.
  28. $TestFeed = new RSS2;
  29. //Setting the channel elements
  30. //Use wrapper functions for common channel elements
  31. $TestFeed->setTitle('Testing & Checking the RSS writer class');
  32. $TestFeed->setLink('http://www.ajaxray.com/projects/rss');
  33. $TestFeed->setDescription('This is a test of creating a RSS 2.0 feed Universal Feed Writer');
  34. //Image title and link must match with the 'title' and 'link' channel elements for valid RSS 2.0
  35. $TestFeed->setImage('Testing & Checking the RSS writer class','http://www.ajaxray.com/projects/rss','http://www.rightbrainsolution.com/_resources/img/logo.png');
  36. //Let's add some feed items: Create two empty Item instances
  37. $itemOne = $TestFeed->createNewItem();
  38. $itemTwo = $TestFeed->createNewItem();
  39. //Add item details
  40. $itemOne->setTitle('The title of the first entry.');
  41. $itemOne->setLink('http://www.google.de');
  42. $itemOne->setDate(time());
  43. $itemOne->setDescription('And here\'s the description of the entry.');
  44. $itemTwo->setTitle('Lorem ipsum');
  45. $itemTwo->setLink('http://www.example.com');
  46. $itemTwo->setDate(1234567890);
  47. $itemTwo->setDescription('Lorem ipsum dolor sit amet, consectetur, adipisci velit');
  48. //Now add the feed item
  49. $TestFeed->addItem($itemOne);
  50. $TestFeed->addItem($itemTwo);
  51. //OK. Everything is done. Now generate the feed.
  52. $TestFeed->printFeed();