Error: Could not fetch http://thedevnet.com/wp-content/plugins/gd-star-rating/css/gdsr.css.php?t=0&s=a10i10m20k20c05r05%23121620243046%23121620243240%23s1pchristmas%23s1pcrystal%23s1pdarkness%23s1poxygen%23s1goxygen_gif%23s1pplain%23s1ppumpkin%23s1psoft%23s1pstarrating%23s1pstarscape%23t1pclassical%23t1pstarrating%23t1gstarrating_gif&ver=1.7.2 for caching. You might need to exclude this file in WP Minify options. The Developer Network – PHP Generate RSS Feeds

PHP Generate RSS Feeds

We are in a new age, content is generated on the fly and posted across the web. Many sites use an RSS feed to try and keep their users up to date with new posts and changed content. Here is a little PHP class that will generate your own RSS feeds and display them in many popular formats.

Formats Supported:

  • RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated), MBOX, OPML, ATOM, ATOM1.0, ATOM0.3, HTML, JS

Step 1 (include the class):

  1. <?php
  2.  // http://thedevnet.com/php/classes/php-generate-rss-feeds/
  3.  include ("include/feedcreator.class.php");
  4. ?>

Step 2 (define a channel):

  1. <?php
  2.  //define channel
  3.  $rss = new UniversalFeedCreator();
  4.  $rss->useCached();
  5.  $rss->title="Personal News Site";
  6.  $rss->description="daily news from me";
  7.  $rss->link="http://mydomain.net/";
  8.  $rss->syndicationURL="http://mydomain.net/$PHP_SELF";
  9. ?>

Step 3 (add the feed items; loop through your data with this):

  1. <?php
  2.  //channel items/entries
  3.  $item = new FeedItem();
  4.  $item->title = "some title";
  5.  $item->link = "http://mydomain.net/news/somelinks.html";
  6.  $item->description = "some description";
  7.  $item->source = "http://mydomain.net";
  8.  $item->author = "my_email@mydomain.net";
  9.  
  10.  
  11.  //optional enclosure support
  12.  $item->enclosure = new EnclosureItem();
  13.  $item->enclosure->url='http://mydomain.net/news/picture.jpg';
  14.  $item->enclosure->length="65905";
  15.  $item->enclosure->type='image/jpeg';
  16.  
  17.  $rss->addItem($item);
  18. ?>

Step 4 (display and/or save):

  1. <?php
  2.  // Valid outputs are RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated),
  3.  // MBOX, OPML, ATOM, ATOM1.0, ATOM0.3, HTML, JS
  4.  
  5.  
  6.  // display
  7.  $rss->outputFeed("ATOM1.0");
  8.  
  9.  // save
  10.  $rss->saveFeed("ATOM1.0", "news/feed.xml");
  11. ?>
Feed Creator
feedcreator_1.7.2.zip
Version: 1.7.2

25.6 KiB
8 Downloads
Details…

GD Star Rating
loading...

Originally posted 2009-10-22 10:29:14.

Popularity: 11%

Posted by natster   @   23 August 2010
Tags : , , , , ,

Like this post? Share it!

RSS Digg Twitter StumbleUpon Delicious Technorati Facebook

0 Comments

No comments yet. Be the first to leave a comment !
Leave a Comment

You must be logged in to post a comment.

Previous Post
« Trim Excess Whitespace
Next Post
PHP Charts »
Powered by Wordpress   |   Lunated designed by ZenVerse