The Microsoft .NET framework includes classes to access Atom Feeds. Since Lotus Quickr is based on Atom feeds, it is possible to build .NET applications that use documents in Quickr.
This wiki article describes a simple application that accesses Quickr documents using an Atom feed. The example application was built using Microsoft Visual C# 2008 Express Edition.
First, it's important to understand the relationship between Atom Feeds and the documents you use in Quickr. Where you see a list of documents in Quickr, and you see the feed icon, that means the list of documents is available as a feed.
For example, when I look at the documents in a folder in Quickr, the list of documents is accessible as a feed.
Clicking on the Feed link shows the contents of the folder as a feed as in this example...
Now, suppose you wanted to build an application that uses those same documents, in C#. This can all be done in a few dozen lines of code.
The first thing you would do is identify the .NET framework classes you need to retrieve and parse the content, and include these in a using statement, along with any other classes you wanted to use (for example for I/O). In this example, we will include...
using System;
using System.Xml;
using System.ServiceModel.Syndication;
using System.Collections.ObjectModel;
using System.IO;
Then, you would need some way for the user to provide the url of the feed, as well as the credentials to use to access the content. In this simple example, we will just use the Windows console for that. In real life of course you would get this information from a form or other, more friendly, user interface. But the console is enough for illustration purposes...
Console.WriteLine("Enter Quickr Feed URL");
String url = Console.ReadLine();
System.Net.NetworkCredential nc = new System.Net.NetworkCredential();
Console.WriteLine("Enter Userid");
nc.UserName = Console.ReadLine();
Console.WriteLine("Enter Password");
nc.Password = Console.ReadLine();
With the URL of the feed and the credentials in hand, it is possible now to request the feed from Quickr, as a standard HTTP request...
System.Net.WebRequest wrq = System.Net.WebRequest.Create(url);
System.Net.CredentialCache cc = new System.Net.CredentialCache();
System.Net.WebResponse wrs = null;
System.IO.Stream ios = null;
Uri uri = new Uri(url);
cc.Add(uri, "basic", nc);
wrq.Credentials = cc;
wrs = wrq.GetResponse();
ios = wrs.GetResponseStream();
Now, it it necessary to parse the response so it is understandable as an Atom feed, and elements from the feed can be used by the application.
XmlReader xr = XmlReader.Create(ios);
System.ServiceModel.Syndication.SyndicationFeed sf = SyndicationFeed.Load(xr);
Then we can start to use the information in the feed. As in this example, where we print some information to the console.
String baseUri = sf.BaseUri.ToString();
Console.WriteLine("Feed Summary...");
Console.WriteLine("\tBase URI: " + baseUri);
Console.WriteLine("\tGenerator: " + sf.Generator);
Console.WriteLine("\tUpdated on: " + sf.LastUpdatedTime);
The documents in this feed are accessible as feed items. In the example, we enumerate those items and print more information to the console...
Console.WriteLine("Items:...");
int i = 1;
foreach (SyndicationItem item in sf.Items)
{
String category = item.Categories[0].Name;
Console.Wr iteL ine("\tItems (" + i++ + ")");
String mainAuthorName = (item.Authors[0]).Name;
String mainAuthorEmail = (item.Authors[0]).Email;
Console.WriteLine("\t\tTitle: " + (item.Title.Text));
Console.WriteLine("\t\tDescription: " + item.Summary.Text);
Console.WriteLine("\t\tCategory: " + item.Categories[0].Name);
Console.WriteLine("\t\tAuthor Name: " + mainAuthorName);
Console.WriteLine("\t\tAuthor email: " + mainAuthorEmail);
Console.WriteLine("\t\tCreated on: " + item.PublishDate);
Console.WriteLine("\t\tUpdated on: " + item.LastUpdatedTime);
Console.WriteLine("\t\tDownload URL: " + baseUri + ((UrlSyndicationContent)item.Content).Url);
}
Running that program shows the same documents you saw before in the browser.
The URL's shown in the console are ones
you can use to download the docu ment from Quickr. For example, if you pasted the URL of one of these documents into a web browser, it would download the document.
Here is the complete program ...