Jump to content

How Can I Use RSS with php and mysql to pull info off a site and use on mine


CStrauss
 Share

Recommended Posts

I'm wanting to learn how I can take information from some of my favorite sites and store them in a database on my site and using php to display the info. I have read bits and pieces of articles that say this is possible using RSS feeds but really unclear where to start about learning this. Most articles I read haven't very clear about RSS not to mention the diffrent versions and which I should use. Then they go in to saying you need an RSS aggetator, but never clear on how to install or use it, or were to sign up for it. So what I'm wanting to know if anyone knows a good book about rss feeds and how to use them for you site to pull information from other sites or to allow your info to be used on other sites. I go to book stores as a first source of trying to learn something new but haven't found any. Another option if anyone knows a good website that takes you through the process of using RSS as I intend to and is pretty up to date That would work also.Also if your pretty knowledagble with rss can you break down everything I need to do get started in learning it if there is no sites or what not as requested to give me a starting point to maybe clear up some of the missing info left out on sites I have already read. for example like first i need to do this then that as sorta of a check list of things i need.Thank you.

Link to comment
Share on other sites

Here is something to start with:

What is RSS?RSS stands for "Really Simple Syndication" and it is a dialect of XML that was created in the late 1990s to allow lists of information, known as "feeds", to be published by content producers and subscribed to by readers. The availability of an RSS news feed is usually indicated by the presence of one of the following buttons: XML - often denotes RSS Feed information. or RSS - often denotes RSS Feed information..RSS is commonly used to pull in content for news-like sites, including major news sites like Wired, news-oriented community sites like Slashdot, and personal weblogs. But it's not just for news. Pretty much anything that can be broken down into discrete items can be syndicated via RSS: the "recent changes" page of a wiki, a changelog of CVS checkins, even the revision history of a book. Once information about each item is in RSS format, an RSS-aware program can check the feed for changes and react to the changes in an appropriate way.RSS-aware programs called news aggregators are popular in the weblogging community. Many weblogs make content available in RSS. A news aggregator can help you keep up with all your favorite weblogs by checking their RSS feeds and displaying new items from each of them. Even web browsers, like Mozilla's Firefox, can automatically keep track of these updates for you, so you always know when new content has been added to your favorite sites. Instead of constantly checking Web pages for changes and additions, Firefox's Live Bookmark delivers updates to you as soon as they are available.PediaLink reads external RSS Feeds and publishes its own as well.How Do I Subscribe?In order to use this service, you will need to download an RSS reader. An RSS reader is a software program that automatically gathers the RSS feeds you select and aggregates them on your desktop or on a customized Web site (e.g., My Yahoo! or Bloglines).Many RSS readers are available, and most of them are free. Additionally, newer versions of some Web browsers (e.g., Firefox and Safari) now support RSS. The Academy does not endorse any particular RSS reader or Web browser and cannot provide technical support for RSS reading—you must download and install at your own risk. For a list of RSS readers, please click here: [url="http://blogspace.com/rss/readers"]http://blogspace.com/rss/readers[/url]In order to subscribe to an RSS feed or newsfeed you will need two things, an RSS reader (also known as a news aggregator) and url (web address) of the RSS feed that you wish to subscribe.       1. Download a News Aggregator / RSS Reader              * A news aggregator or RSS reader is a software application that collects and displays news headlines and summaries from sources that you have designated.       2. Install the feed reader or news aggregator on the computer       3. Click on the RSS Subscribe Icon Subscribe to this feed! and the feed (XML file) will open in a new window.       4. Copy the URL from your web browser.       5. Insert the url of the news feed (there is usually an "add feed" button) into your feed reader or news aggregator       6. Many of the news readers will allow you to set the interval that the software will look for a feed update others simply update daily.       7. The information in the feed will be updated when the feed contains new content.Why do I see "code" when I click on the RSS links?RSS feeds are designed to be viewed with RSS readers (see above). If you view the RSS feed in a standard Web browser you will see the tagged data in its "raw" format.

Then, you might want to review:http://www.w3schools.com/rss/As far as incorporating RSS into your site, bascially you do not need a database. by site:http://www.iribbit.net/i/news.cfmdoesn't use a database - it simply pulls the feed into my site and parses the XML and displays it. My site uses ColdFusion, but since you are interested in using PHP, try this:http://www.google.com/search?q=php+parse+rssBasically, you code a page that parses the XML (via the source url) and then you format the page to display it.

Link to comment
Share on other sites

I have a code (for my own blog), which uses PHP and reads out of a database.Here's the code I use.

<?$obj = new db();$obj->koble_til();$obj->skrivut();$obj->steng_db();//Lager en klasseclass db{//Noen variablervar $hostname = "localhost";var $username = "mysql_username";var $password = "mysql_password";var $usertable = "mysql_table";var $dbName = "mysql_database";var $result;function koble_til(){//mysql_connect($this->hostname,$this->username,$this->password) || die(mysql_error());@mysql_select_db($this->dbName)  || die("Unable to select database");}function query($query){$data = array();$this->result = mysql_query($query);if(mysql_num_rows($this->result) != 0){ while($d = mysql_fetch_object($this->result)){  $data[] = $d; } return $data;}return null;}function skrivut(){$result = $this->query("SELECT * FROM $this->usertable ORDER BY id");if (!is_null($result)){ $now = date('d.m-Y@H:i:s', time()); $rss = <<<RSS <rss version="2.0">  <channel>\n  <title>Anders Moen - www.andersmoen.com</title>  <description>Anders Moen's RSS feed</description>  <lastBuildDate>$now</lastBuildDate>  <link></link>RSS;	 foreach($result as $r){	  $date = date('d/m/Y@H:i:s', $r->timestamp);	   $rss .=<<<RSS			<item>	<title>$r->title</title>	<pubDate>$r->date</pubDate> 	<description>$r->c_in$r->c_con</description>	<link>http://andersmoen.com/blog/archive/$r->id/</link>   </item>RSS; } $rss .="</channel></rss>";header('Content-type:text/xml');print $rss;}}function steng_db(){mysql_free_result($this->result);mysql_close();}}?>

I got this code on a Norwegian webforum in the "PHP-pub" or something like that, and if you want to see how it works: www.andersmoen.com/feed.php

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...