

In the code above, I have used the file_get_contents function, which returns false on failure. I have used simple XML element to read the. If this condition is true, the feed’s actual XML content is fetched by using one of the PHP functions for getting the source code of an URL. Recently I had a project that involved reading RSS feeds.I have created a simple PHP Script to read RSS Feed. Notice that RSS feed frequency is stored in minutes, so it has to be multiplied by 60. A feed should be fetched if the number of seconds elapsed between the current time and the last access time is larger than the feed’s access frequency. After that, we loop through the array and check which feeds should be fetched.
#Php rss feed reader script free
I have used the basic PHP functions for connecting to the database, but feel free to replace them with your own database manipulation class. Mysql_query("UPDATE feed SET last_access='".time()."' WHERE id='".$feed."'") įirst, the list of RSS feeds is fetched from the database and stored into an array. $insert_q = "INSERT IGNORE INTO article (title,content,url,pub_date,insert_date) VALUES ( $content = file_get_contents($row) // this could be done with cURL Although this can be done on the fly, it would be quite slow, so we would rather use the database table to store and fetch data: If you found this tutorial helpful then don't forget to share. Loop through the returned Object to read contents. The main task of an RSS aggregator is to combine data from multiple feeds and display them as one list. Use simplexmlloadfile () method to read RSS feeds of the website. 4.) Pass your feed to the RSS2HTML server which will display the feed in an html format free of charge. We need four inputs, one is title (this will be used as anchored text so important for our keyword ranking), Link (the URL of the page), description and publication date. Here the form is designed to take data as per the required format of RSS feed. Unlike the description tag, content:encoded can contain HTML tags, which is shown in the example above. Put a free copy of the rss2html.php script on your webserver and edit its feed and template variables 3.) Run the rss2html.php script from a server, passing it the URLs of your feed and webpage template files free of charge. The first step is creating a form and then storing the entered data to a table. The purpose of this tag is to overcome limitations of the description tag, which allows only plain text. However, there is one more tag that has become often used nowadays: content:encoded. There are many other tags that can be used in RSS feeds, but they are optional and rarely used. As well as the other dates and times in RSS, pubDate conforms to the Date and Time Specification of RFC 822.

#Php rss feed reader script full
Title and description represent the title and description of the content, link is the full URL to that content, guid is a unique identification of the particular article (usually the URL) and pubDate is the time when content is published. Items usually have the following data: title, description, link, guid and pubDate. After that, there is some data describing the feed itself, such as the title and the description of the RSS feed. At the beginning of the document, the encoding and RSS version are defined.
