Showing posts with label RSS reader. Show all posts
Showing posts with label RSS reader. Show all posts

Tuesday 29 August 2017

Host Your Own RSS Feed Reader

rss feed
How to create an RSS feed from scratch


Today most of the systems we implement (such as WordPress) already come with a feed created and implemented, ready to validate, it is always possible to create a zero, or want to further customize what already exists.

Through a simple tutorial we will teach you to create an RSS feed from scratch, whether with static or dynamic content.

As always, first things first:

Reqirements for RSS feed:


A website with content, whether static or dynamic.

A Web editor.

Process of creating RSS feed:


To create an RSS feed, it is necessary to encode a file in XML format, which contains the necessary tags to interpret and display the content in the specified format, to which users will access. This file we can leave it native in XML, or embed it inside PHP, as we will see in both cases below.

For this we will perform 2 processes. In the first instance we will create a static feed, from content that we have available on our site.

After that we will repeat the task, but this time we will retrieve contents from a database to put them into the feed, ideal if they are publishing through a CMS or if they obtain content directly from a database.

So without further ado, let's get down to business:

1.- Creating a static RSS feed


This option is valid only if we have static content on our site, which although not very justified, can be a useful functionality to deliver to visitors.

For this, we need to create an XML file in our Web editor, and start coding:

The first 2 lines that we added correspond to the definition of the version and coding of xml (in order for it to validate correctly we must add the version, as far as the coding is optional but it never is) and the version of RSS that will use The file we are creating. Currently most sites offer subscriptions for both RSS 1.1 and 2.0, but with the latter is more than enough. At the end we close the rss tag to finish the document.

Following the above, it is necessary that everything related to the feed (both information and content), be included within the </ channel> tags, which we will add just after the previous code.

And now, inside the channel tags we will be adding the feed information.

And finally, after the information, we add the related content that will be displayed in the feed, we will do this by repeating the same tags we used previously, but closed between < item>and </ item>:

The above we save it with any name and with extension xml, we upload it and when opening it in the navigator we will be able to see that our static feed is completely ready:

2.- Creating a dynamic RSS feed


We created our static feed, its just onnly a few minutes, we realized that it was very simple and we are ready to conquer the world ... right ?. Well, not yet. As we indicated in the previous point, a static feed is not very funny, since we must add each new content manually and ends up being a lot of work, or it may be that on more than one occasion we forget to update. Due to this, if we have a site where the content is obtained dynamically from a database, it is possible to adapt that to our feed and that the new information will be added as it is generated. For this, we will work with both XML and PHP, in a bombastic that will spark and make us the most popular kids in high school.

For this, we will consider that we have a database, which has a news table with a title field, a link field, a detail field and a date field of the news, as we see below:

[Table id = 1 /]

So, the first thing to do is create a PHP file in our Web editor.

As you can see, in the previous code we left a blank section, between the <? Php and?> Tags. This part of the code is where we will connect to the database, rescue the news and deploy it dynamically.

For this, we will first connect to the database. As a good practice we will use DEFINE to define redundancy, define the connection data, but if you want, you can skip this part and execute the function directly:

And now we make the connection. We run the query.

Now that we have retrieved all the news from the database in an orderly way by date, obtaining the newest ones first, we will pass them to an array to write them in the specified XML format, as follows:

With the above, we execute a cycle that will pass to an array in an associative way (thanks to the parameter MYSQL_ASSOC, which will allow us to access the records in the array with the same name that they have in the table of the database). That they are finished and will create a new item with the respective values to include in the feed.

With that we are almost ready, the last detail is to add a small header at the beginning of the document, indicating that we are executing XML content for better recognition at the time of executing the complete script, we do this by adding at the beginning.

And ready!.

We have our dynamic RSS feed, which will add the results obtained from the database and each time we publish new content will be updated automatically.

And now, to conquer the world ?. Not yet. Before finishing:

3.- Useful tips for launching RSS feed


Some tips that are never over:

Validate feed

Before launching our feed to the public, it's good to make sure that it works properly and that we have not made coding errors. For this we can validate through several services, such as:

W3C Validator

Feed Validator

Just add the URL of our feed and validate.

Publish the feed

There are services that allow us to publish our feed and offer a series of interesting features, such as adding advertising or statistics about our subscribers. The best known and undoubtedly used is Feedburner, which in only moments we can publish our feed without problems.

Show users that a RSS feed exists on the site

If at this moment they look at the address bar of your browser, you will see that there is an orange icon.
This icon indicates that the site has an RSS feed to which they can subscribe. How to add it? Very simple, we should only add the following lines between the <head> and </ head> tags of each page we want it to appear in, such as a favicon. Simple, right?

and </ head> tags of each page we want it to appear in, such as a favicon. Simple, right?

Customize your RSS feed


The details certainly make the difference in the minds of the users. So, now that we've learned how to make a feed from scratch, why not play it a bit and make it more personalized? Only by modifying small parts of the code can we display certain types of information in our feed (for example comments if they exist), or limit the number of articles to be displayed, or make a separate feed for each person that writes in the site and thus each Reader follow his favorite author.

The possibilities are many, you just have to experiment.

And with this we have finished this tutorial in which we have covered the process of creating an RSS feed from scratch. As you can see, it only takes a few minutes and the difficulty is low, so we encourage you to try and tell us your experience.

Before ending, we remind you that as always, this tutorial has been:

Any questions or comments you may have, we invite you to leave us a few lines in the area enabled below.
We hope this tutorial has been useful for you.

Saturday 31 August 2013

Digg finally arrives on Android


Digg, the RSS reader of Betaworks, has announced the launch of its Android application. Of course, it allows you to enjoy the "Top Stories” articles handpicked, as well as the aggregator. However, some important features still missing as display only unread content and synchronization in the background. Following the announcement of the closure of Google Reader, Digg decided to embark on the adventure of RSS aggregators. Indeed, the company was proposing a community site or the users voted for they considered relevant or the useful content. The most interesting and or popular were then highlighted. Digg request user feedback but do not necessarily take into account. But before diving Digg organized several surveys to collect the opinions of Internet users, the goal was to offer a product that meets their expectations. But in practice, there is sometimes a gap: while the direct sharing by email and research streams were in high demand, they are not yet available in Digg Reader as currently proposed.

 However, the company does not remain inactive and just put online a first version of its highly anticipated Android app too, obviously. Anyway, after two months of waiting, it is now available, but it sorely lacks some basic features. It is obviously possible to navigate through the “Top Stories” and in your various RSS feeds, save (via Pocket, Instapaper and Readability) and share via social networks. In addition, you can sort, add and delete files and streams. By cons, this first version do not displays your unread content, which is unfortunate. Note that when the closure of Google Reader in early July, the site was in the same situation, but this feature is quickly arriving later, hope it will be the same here. It is not possible to change the screen orientation (portrait by default), the font size and activate the update stream in the background. This should, however, make an appearance before the announcement of the Premium model, long planned.