====== Création RSS par PHP ======
class RSSFeed { // VARIABLES // channel vars var $channel_url; var $channel_title; var $channel_description; var $channel_lang; var $channel_copyright; var $channel_date; var $channel_creator; var $channel_subject; // image var $image_url; // items var $items = array(); var $nritems; // FUNCTIONS // constructor function RSSFeed() { $this->nritems=0; $this->channel_url=''; $this->channel_title=''; $this->channel_description=''; $this->channel_lang=''; $this->channel_copyright=''; $this->channel_date=''; $this->channel_creator=''; $this->channel_subject=''; $this->image_url=''; } // set channel vars function SetChannel($url, $title, $description, $lang, $copyright, $creator, $subject) { $this->channel_url=$url; $this->channel_title=$title; $this->channel_description=$description; $this->channel_lang=$lang; $this->channel_copyright=$copyright; $this->channel_date=date("Y-m-d").'T'.date("H:i:s").'+01:00'; $this->channel_creator=$creator; $this->channel_subject=$subject; } // set image function SetImage($url) { $this->image_url=$url; } // set item function SetItem($url, $title, $description) { $this->items[$this->nritems]['url']=$url; $this->items[$this->nritems]['title']=$title; $this->items[$this->nritems]['description']=$description; $this->nritems++; } // output feed function Output() { $output = ''."\n"; $output .= ''."\n"; $output .= ''."\n"; $output .= ''.$this->channel_title.''."\n"; $output .= ''.$this->channel_url.''."\n"; $output .= ''.$this->channel_description.''."\n"; $output .= ''.$this->channel_lang.''."\n"; $output .= ''.$this->channel_copyright.''."\n"; $output .= ''.$this->channel_date.''."\n"; $output .= ''.$this->channel_creator.''."\n"; $output .= ''.$this->channel_subject.''."\n"; $output .= ''."\n"; $output .= ''; for($k=0; $k<$this->nritems; $k++) { $output .= ''."\n"; }; $output .= ''."\n"; $output .= ''."\n"; $output .= ''."\n"; $output .= ''."\n"; for($k=0; $k<$this->nritems; $k++) { $output .= ''."\n"; $output .= ''.$this->items[$k]['title'].''."\n"; $output .= ''.$this->items[$k]['url'].''."\n"; $output .= ''.$this->items[$k]['description'].''."\n"; $output .= ''.$this->items[$k]['url'].''."\n"; $output .= ''."\n"; }; $output .= ''."\n"; return $output; } }; $myfeed = new RSSFeed(); $myfeed->SetChannel('http://www.echosystem.fr/images.rss', 'My feed name', 'My feed description', 'en-us', 'My copyright text', 'me', 'my subject'); $myfeed->SetImage('http://www.echosystem.fr/images/echosystem.png'); $myfeed->SetItem('http://www.echosystem.fr/blog', 'name', 'description'); .... echo $myfeed->output();
{{tag>rss script}}