Delete feed items older than 1 week (to keep my database light).I'm hosting this in an NGINX protected path in my VPS and I've set 2 cron jobs: fetch( ` $) Code language: JavaScript ( javascript ) □ VPS Fetch APIįrom the Vue components I simply use the Fetch API to call my PHP and query the database. Then for the components BoostrapVue is a wonderful choice to get a bunch of components plug and play, ready to use. You don't have to think about build systems and whatnot. To create the Vue app I used the Vue CLI which is fantastic for this kind of projects. $_GET) Code language: PHP ( php ) □ Vue CLI + BootstrapVue Added this line to print the output in proper xml format header(Content-type: text/xml) So this piece of code will be taken care of the xml structured output for our script. Not too complicated: $mysqli->query( "update ". Look at the snippet below, it queries the database to update an item's field. Then it's just a matter of querying the MySQL database to store the results. This allows you to read the XML feed files. This function is the key of the whole thing. If that's what you want, this RSS Reader is not for you. Not everybody likes that, some just want the regular pain text version. Sure I don't have "inline preview" as I would have in Feedly but I prefer to see the post in its original context. You could have categories and other features, I don't need them. Mark items as read (when you click the link or hit the read button).So not much fricction.īecause I'm a Front-end developer I had to drop in a bunch of node packages □ Well, I'm using Vue for this RSS Reader. I'm somewhat confortable with PHP, I remember enough of MySQL and my VPS already has both installed. You can use many other tools that will also get the job done. I built it with PHP and MySQL, it's easy and straightfoward. Turns out there is, I took a very simply implementation and refactored it to fit my needs. □♂️ How do you build an RSS Reader?įirst thing you do is do a Github search see if there's any open source project with proper license you can fork. It's a small step but now there's one less company that knows the sites I read, what I like, don't like, etc. □ Why build my own?įirst because I can and perhaps more importantly because privacy. I don't really use categories, sharing or other features. I used to use Feedly and there was nothing wrong with it. Please tell me you still use RSS □, you should, everybody should. The following code shows how to use DOMDocument to work with the rss feed from a url.Before you eye roll me □ after saying PHP, hear me out. It is a DOM parser which makes it easier for you to read the xml data. Running this script will produce an output like this,Īs I said earlier, there is another way to read the rss feeds and that is to use the DOM extension php library. Next, add a new folder called feeds, and then create a new file called. Now you have to call the above read_rss_feed() function and display the feed lists wherever you want. To create your feed, you need to create a new folder and file in the simpleblog project. 'description' => implode(' ', array_slice(explode(' ', $item->description), 0, 40)) How does it work The script pulls news articles in from RSS feeds that you specify in the administration panel. It gets the feed contents from an rss url, loops through it and returns the property of each feed item into an array. PHP RSS Reader is a full blown news aggregation script programmed in PHP that allows you to provide your users with fresh content 24/7. Below is the small php function to read the rss feed from the given feed url. This function interprets the xml file into an object array. Simple XML Parser in PHP supports a native function called simplexml_load_file() to read xml file. How to Read RSS Feed in PHP using Simple XML Parser?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |