What are feeds?
A web feed lets websites continuously “feed” you notices of their new content. This feed can be picked up by a news reader, another website or an app. Feeds also make it possible for site content to be packaged into "widgets," "gadgets," mobile devices, and other bite-sized technologies that make it possible to display blogs, podcasts, and major news/sports/weather/whatever headlines just about anywhere.
You may hear things like RSS, XML , ATOM or JSON and not be really sure what they are or what they do. They are basically just different ways in which text is formatted and passed along as a feed.
XML is a standard that defines how to structure a text document, to store information in an organized way in that document. RSS and ATOM are variants of this standard specific to web feeds.
JSON is a different standard way of passing data and is particularly useful for when using the Javascript programming language which is commonly used on the Web.
RSS feed example:
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>Example 1</title>
<link>http://www.yudu.com</link>
<description>An example of how an RSS feed is composed</description>
<item>
<title>RSS Tutorial</title>
<link>http://www.yudu.com/rss</link>
<description>Here is another example</description>
</item>
<item>
<title>Another Title </title>
<link>http://www.yudu.com/another</link>
<description>A third example</description>
</item>
</channel>
</rss>
JSON feed example:
{
"feed":[
{
"link":"http://www.yudu.com/example",
"title":"This is an example title",
"image":"http://www.yudu.com/example.jpg",
"description":"An example blog about how JSON feeds work …"
},
{
"link":"http://www.yudu.com/example",
"title":"This is an example title",
"image":"http://www.yudu.com/example.jpg",
"description":"An example blog about how JSON feeds work …"
}
]
}
What formats do we require?
Currently the 2 types of feeds that we accept for inclusion in our apps are RSS 2.0 and JSON.
RSS 2.0
If we receive an RSS 2.0 feed we pass this data first to the Google Feed API which returns us a valid JSON string. So we are essentially always working with JSON data. By passing the RSS feed to the Google API we have 2 benefits. Firstly the returned data is a JSON string formatted in a way which makes it very easy for us to integrate into our apps. Secondly through using the Google API we are able to access the relevant JSON without getting any cross domain problems.
To check that an RSS 2.0 feed is suitable for us to use please do the following:
1/ Obtain the url for your RSS 2.0 feed e.g http://www.thehrdirector.com/blog/feed/
2 / Append it to the following URL
http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=100&q=
3/ This will give you a URL like this : http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=100&q=http://www.thehrdirector.com/blog/feed/
4/ View this URL in any browser and if your feed is the correct format you should see a list of JSON data on the screen. Don’t worry if it seems all garbled. So long as there are no errors everything should be fine.
JSON
If you prefer to provide us a customised JSON string then that is also acceptable. There are several benefits to providing a feed in this way.
You will be able to customise the data fields exactly to your requirements. If the feed output needs to be structured or designed in a certain way this could be useful.
This cuts out the step of using the Google feed API as the data is already in JSON format. This should speed things up and means there is no reliance on Google if they were ever to stop providing the service.
Any images can be encoded in base64 and not rely on hard coded urls for presentation in the app. This would be useful if you wanted to provide offline functionality.
If you are planning to provide a custom JSON feed it is important that measures are taken to ensure that the feed is accessible cross domain.
Cross Domain Issues
As the feed data is coming in to the app from an unfamiliar location one problem that often occurs is the inability to access the feed. The feeds are blocked by all web browsers as they are considered a security risk. Potentially any code could be injected into the feed and this would cause obvious security concerns.
There are 2 ways in which we can get around this problem.
1. If you have access to the web server where the feed is hosted then the .htaccess file can be set to allow cross domain requests.
2. The JSON feed needs to be wrapped in a callback function which is executed once the data is received by the app. We can access the data using a method known as JSONP by sending the feed url a query string which will be the name of the callback. This callback is then wrapped around the json data on the server and then output. Please contact us for further detail regarding this if required.
N.B if you are only providing an RSS 2.0 feed you do not need to worry about cross domain issues as the Google feed API will take care of it.