Twitter has an API implementation that is very simple to understand and use. Here is how it works, if you want to get the friends timeline of a user.
http://twitter.com/statuses/friends_timeline.rss
Here there are 3 keywords.
What are you working on? statuses
What do you need from the above object? friends_timeline
In what format do you need it? RSS
Formats supported are: xml, json, rss, atom
Methods supported: See Twitter API
There are many objects supported, but the above format applies for only a few like Statuses, User, Direct Messages. The rest are also similar.
Now, let us look at a GET to bring in Friend Status.
First off, we would need the URL above
public string GetFriendsStatus()
{
return InvokeAPI("friends_timeline", "statuses", "rss");
}
public string GetUrl(string action, string target, string format)
{
return String.Format("http://twitter.com/{0}/{1}.{2}", target.ToLower(), action.ToLower(), format.ToLower());
}
private string InvokeAPI(string action, string target, string format)
{
return AskTwitter(GetUrl(action,target,format), this.User);
}
The public method GetFriendsStatus calls a generic method InvokeAPI to (surprise!) invoke the API. This function in turn relies on GetUrl to build the URL for this request. AskTwitter is a helper method that does a GET request and returns the result.
public static string AskTwitter(string Url, NetworkCredential nwUser)
{
try
{
WebClient client = new WebClient();
if(User!=null) client.Credentials = nwUser;
Stream stream = client.OpenRead(Url);
StreamReader reader = new StreamReader(stream);
return reader.ReadToEnd();
}
catch (WebException ex)
{
if (ex.Response is HttpWebResponse)
{
if ((ex.Response as HttpWebResponse).StatusCode == HttpStatusCode.NotFound)
{
return null;
}
}
throw ex;
}
}
As you can see, AskTwitter takes in 2 parameters. First one is the URL we built earlier. The second parameter is user credential, for requests that require credentials. This can be built easily as below.
NetworkCredential nwUser = new NetworkCredential("UserName", "Password");
Hope that helped get you started. Am working on a complete set of wrappers that will make using these APIs much more easier. Please leave a comment and let me know if you would be interested in any specific features.