How To Add Rss Feeds Into Your Website Using Php
Hello Friends,
Hello Friends,
As a webmaster you would interested in having search engine friendly RSS feeds on your web pages because this can help with;
RSS in Javascript format is available from most RSS Publishers but what they do not tell you is that Javascript is not search engine friendly. What that means is search engines do not read Javascript. Any thing placed on your web pages in javascript format won't be read by the indexing search engines. That is why they offer our feeds in PHP. PHP is a search engine friendly scripting language. Adding RSS feeds to your web pages with PHP will provide fresh content for the search engines to choose up and rank you for.
PHP is server side scripting. That means it is parsed on the server before your page lots in the browser. To the visitor and to the search engines PHP scripts are not noticeable. When PHP is combined with RSS feeds it is a powerful idea. With PHP and RSS you can add other people's content to your web pages and the search engines will see it and think it is part of your net site! That free RSS content when placed on your web page with PHP will fundamentally become a part of your web-site and bring you more traffic. That is why they recommend that you add the feeds to your net site with PHP in lieu of Javascript. Follow the instructions below to add the code to your web pages. Getting spidered more often Rating higher in the search engines Adding Relevancy to your web page.
I had a lot of trouble trying to add RSS Feeds on my website. Eventually I came across these codes and they were very helpful.
PHP Code:
----------------------
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 = ''."
";
$output .= ''."
";
$output .= ''."
";
$output .= ''.$this->channel_title.''."
";
$output .= ''.$this->channel_url.''."
";
$output .= ''.$this->channel_description.''."
";
$output .= ''.$this->channel_lang.''."
";
$output .= ''.$this->channel_copyright.''."
";
$output .= ''.$this->channel_date.''."
";
$output .= ''.$this->channel_creator.''."
";
$output .= ''.$this->channel_subject.''."
";
$output .= ''."
";
$output .= '';
for($k=0; $knritems; $k++) {
$output .= ''."
";
};
$output .= ''."
";
$output .= ''."
";
$output .= ''."
";
$output .= ''."
";
for($k=0; $knritems; $k++) {
$output .= ''."
";
$output .= ''.$this->items[$k]['title'].''."
";
$output .= ''.$this->items[$k]['url'].''."
";
$output .= ''.$this->items[$k]['description'].''."
";
$output .= ''.$this->items[$k]['url'].''."
";
$output .= ''."
";
};
$output .= ''."
";
return $output;
}
};
You would use it like this :
php Code:
$myfeed = new RSSFeed();
$myfeed->SetChannel('http://www.mysite.com/xml.rss',
'My feed name',
'My feed description',
'en-us',
'My copyright text',
'me',
'my subject');
$myfeed->SetImage('http://www.mysite.com/mylogo.jpg');
$myfeed->SetItem('http://www.mysite.com/article.php?id=bla',
'name',
'description');
....
echo $myfeed->output();
I also discovered that there was a cron script that runs every now and then that writes the output to a an xml file. It ran through a feed validator and was validated.
by: LisaJhonson
Websites That Make Off-site Optimization For Seo Effective Some Skill To Promote Website Ranking Win Barbados Holidays With "barbados Likes You" Facebook Promotion Advanced Ecommerce Website Design Service Essential Aspects Of Website Design Website Redesign: Do You Really Need It? Useful Tips For Website Design To Make A Website Ceramic Mugs Are Popular Promotional Gifts Productive Website Design Atlanta Ga Learn More About Where To Get Links For Any Website Turn Your Website Into An Interactive Platform With Php How Joomla Helps In Improving The Functionality Of The Website The Need To Purchase High Quality Composite Toe Boots