RSS feed stuff

You may have noticed that I added a news feed toward the bottom of the gray “nav” bar on the left. For now it’s mostly just an experiment, so it’s very subject to change.

Right now it’s pulling, formatting it, and dumping it over there. At first, I was using a script made of a few functions I found to format the XML. It had the URL of the feed right in the code. snpxml.php.txt is the code for that. I thought it would be much easier if I could send the feed’s URL as a parameter, instead of hardcoding it into the script. After a few minutes of searching, I found out that PHP will automatically make variables for anything it finds in the querystring. That made my conversion infinitely easier. Instead of setting up a bunch of junk to create a variable in the function that got the data from the querystring, I just had to remove the existing declaration for $feed and tack it on when I called the script. readnews.php.txt is the new script (with $feed removed at the beginning). Now I just have to call it with something like Now PHP automatically converts the URL passed in the querystring to $feed, and I don’t need to change anything else for it to work. I also added in a bit of error correction so that it exits if you don’t pass it a value.

Leave a Reply

Your email address will not be published. Required fields are marked *

Note: This post is over 5 years old. You may want to check later in this blog to see if there is new information relevant to your comment.