![]() In the code above, I have used the file_get_contents function, which returns false on failure. 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. 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. 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 ( The minimum requirements needed to successfully run Lilina are: PHP 5.2 or higher, PHP’s XML extension, PHP’s PCRE extension and PHP’s JSON extension. You can import feed as OPML, the standard for feed sharing. It uses no database and supports both RSS and Atom feed. $content = file_get_contents($row) // this could be done with cURL Lilina is a PHP open source feed news aggregator script powered by SimplePie. This script supports the following attributes (fields) by default but can easily be. 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: This class is by no means the be-all and end-all of RSS parsing. ![]() The main task of an RSS aggregator is to combine data from multiple feeds and display them as one list. ![]() If you found this tutorial helpful then don't forget to share. Loop through the returned Object to read contents. Unlike the description tag, content:encoded can contain HTML tags, which is shown in the example above. Use simplexmlloadfile () method to read RSS feeds of the website. The purpose of this tag is to overcome limitations of the description tag, which allows only plain text. I have used simple XML element to read the. However, there is one more tag that has become often used nowadays: content:encoded. Recently I had a project that involved reading RSS feeds.I have created a simple PHP Script to read RSS Feed. 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. 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |