PHP RSS Feed Generator Class 13


English Version | Versão Portuguesa



It’s been a while since I’ve planned on developing a new platform for my work as Web Developer, and next to all Web Developers, and I started to develop some modules and this RSS Generator Class born to fulfill my needs.

Supported versions:
RSS 2.0

Download:
Download it

Features:
Generates RSS 2.0 feeds
All feeds are validated by feed validator
Supports all feed elements
Simple & easy to define channel proprieties
Simple & easy to define item elements
Enables usage of sub-tags and attributes

Example

It’s a minimum “how to” example needed to understand how to use this class. It’s part of the download package.

include( "feed.php" );
 
	//Create a new Feed
	$feed = new Feed( );
 
	//Setting the channel elements
	//Helper -> http://www.rssboard.org/rss-specification
	$feed->setFeedTitle( 'Demo - RSS Generator Class' );
	$feed->setFeedLink( 'http://joaopedropereira.com/blog/rss' );
	$feed->setFeedDesc( 'This is demo of generating a RSS feed. ONLY RSS Version 2.0 Supported' );
	$feed->setFeedImage( 'Oh, my photo...', 'http://joaopedropereira.com/projects/rss_gen', 'http://s3.amazonaws.com/twitter_production/profile_images/63969619/imagemresized.jpg' );
 
	//Is possible to use setChannelElm() function for setting other optional channel elements
	$feed->setChannelElm( 'language', 'en-us' );
 
	//Create a new Item
	$item1 = new Item( );
 
	//Setting the Item elements
	//Helper -> http://www.rssboard.org/rss-specification
	$item1->setItemTitle( 'Item nº 1' );
	$item1->setItemLink( 'http://joaopedropereira.com' );
	$item1->setItemDate( time( ) );
	$item1->setItemDesc( 'Bla, bla, bla, item nº 1.' );
	$item1->setItemEnclosure( 'http://www.beardodisco.com/beatelectric/music/Loverboy12Mix.mp3', '17121349', 'audio/mpeg' );
	$item1->setItemAuthor( 'contacto@joaopedropereira.com (João Pedro Pereira)' );
	//As in Channel is possible to use setItemElm() function for setting other optional item elements
 
	//Create another Item
	$item2 = new Item( 'Item nº 2', 'http://twitter.com/joaoppereira', 'Bla, bla, bla, twitter of the owner of the blog of a webdeveloper' );
 
	$item2->setItemDate( time( ) );
	$item2->setItemAuthor( 'contacto@joaopedropereira.com (João Pedro Pereira)' );
 
	//Adding both created items
	$feed->addItem( $item1 );
	$feed->addItem( $item2 );
 
	//Now we're ready to generate the Feed, Awesome!
	$feed->genFeed( );

Download | Demo

Download | Demo

EDIT

HOT NEWS, PHP XML-RSS Feed Generator Was Accepted on PHPClasses.org!!


Há já algum tempo que pretendo desenvolver uma nova plataforma para o meu trabalho como Web Developer, e numa fase posterior abrir como serviço para todos os Web Developers, e por isso comecei a desenvolver alguns módulos para essa plataforma, trabalho que deu, entre outros, no módulo de RSS Feed’s surgindo assim a RSS Generator Class para satisfazer as necessidades.

Versões Suportadas:
RSS 2.0

Download:
Download it

Funcionalidades:
Gera RSS Feeds versão 2.0
As feeds são válidas conforme o feed validator
Suporta todos os elementos quer dos channel’s quer dos item’s
É simples definir as propriedades do channel
É simples definir as propriedades dos items

É possível utilizar sub-tags e atributos

Exemplo

Um pequeno exemplo que mostra como se pode fazer uso desta classe. Faz parte do pacote disponível para download.

include( "feed.php" );
 
	//Create a new Feed
	$feed = new Feed( );
 
	//Setting the channel elements
	//Helper -> http://www.rssboard.org/rss-specification
	$feed->setFeedTitle( 'Demo - RSS Generator Class' );
	$feed->setFeedLink( 'http://joaopedropereira.com/blog/rss' );
	$feed->setFeedDesc( 'This is demo of generating a RSS feed. ONLY RSS Version 2.0 Supported' );
	$feed->setFeedImage( 'Oh, my photo...', 'http://joaopedropereira.com/projects/rss_gen', 'http://s3.amazonaws.com/twitter_production/profile_images/63969619/imagemresized.jpg' );
 
	//Is possible to use setChannelElm() function for setting other optional channel elements
	$feed->setChannelElm( 'language', 'en-us' );
 
	//Create a new Item
	$item1 = new Item( );
 
	//Setting the Item elements
	//Helper -> http://www.rssboard.org/rss-specification
	$item1->setItemTitle( 'Item nº 1' );
	$item1->setItemLink( 'http://joaopedropereira.com' );
	$item1->setItemDate( time( ) );
	$item1->setItemDesc( 'Bla, bla, bla, item nº 1.' );
	$item1->setItemEnclosure( 'http://www.beardodisco.com/beatelectric/music/Loverboy12Mix.mp3', '17121349', 'audio/mpeg' );
	$item1->setItemAuthor( 'contacto@joaopedropereira.com (João Pedro Pereira)' );
	//As in Channel is possible to use setItemElm() function for setting other optional item elements
 
	//Create another Item
	$item2 = new Item( 'Item nº 2', 'http://twitter.com/joaoppereira', 'Bla, bla, bla, twitter of the owner of the blog of a webdeveloper' );
 
	$item2->setItemDate( time( ) );
	$item2->setItemAuthor( 'contacto@joaopedropereira.com (João Pedro Pereira)' );
 
	//Adding both created items
	$feed->addItem( $item1 );
	$feed->addItem( $item2 );
 
	//Now we're ready to generate the Feed, Awesome!
	$feed->genFeed( );

Download | Demo

EDIT

HOT NEWS, PHP XML-RSS Feed Generator foi aceite no PHPClasses.org!!


Leave a Reply

13 thoughts on “PHP RSS Feed Generator Class