We recently added a PHP based RSS reader in our includes folder for people to start using with their php based pages. It’s a simple tool to use, only 3 lines of code needed (well 2 if you don’t create the $url variable). Anyway here’s an example on how to use it.
[code lang="php"] [/code]
Now that we have seen it here’s how it works:
- The first line loads the library file that does all the heavy lifting
- The second line is the URL variable. You simply need to put your news feed url here. In this case we are displaying the headlines from the UWGB news site “Inside”.
- Last but now least we need to echo out the results of the RSS_Display funtion.
There are four parameters for the RSS_Display function:
- $url – [Format = URL] – this parameter if the URL to the feed you want to display
- $size – [Format = Integer] – this determines how many feed items to display (Default 15 items)
- $site – [Format = True or False] – displays or hides the title and the description of the site (Default false)
- $showDate [Format = True or False] – displays or hides dates (Default false)
- $dateFormat [Format = String] – determines how dates are display using the PHP Time Format Manual (Default “Y-m-d H:i:s”)
If you have questions feel free to post comments below.