A .net 3.5 wrapper for the Twitter API

Author: Deepak Prasad (dee@newbtech.com)
Version: 1.0.0.4 (Alpha) – PREVIEW RELEASE

Latest News (19 October 2009)

Ability to retrieve a specified user’s followers (just their Id’s) in version 1.0.0.4
Ability to retrieve a specified user’s details (given their screen id) in version 1.0.0.4

Introduction

This library provides a simple .net interface for the Twitter API. The main Twitter API documentation is here: (http://apiwiki.twitter.com/Twitter-API-Documentation). What the NewbtechTwitter library tries to do is wrap as many of these calls as possible and returns back friendly objects that you can access to get the most out of the Twitter API’s.

Note: It makes use of the XML Web Services of the Twitter API.

Release Notes

As development is continuing, the latest release notes can always be found here: http://www.newbtech.com/twitterapiwrapper/release-notes

Methods Available

You can review the complete list of methods here:
http://www.newbtech.com/twitterapiwrapper/methods-available (updated 1.0.0.4 – 19 October 2009).

More methods will be made available in subsequent releases. If there is any one in particular that you are looking for, please let me know.

Prerequisites

Visual Studio 2008 with .Net 3.5 SP1

Download

To download, use the following link :

Latest build: Version 1004 (October 19, 2009)
- http://www.newbtech.com/TwitterAPI/Newbtech.TwitterAPI.1004.zip  (release notes)

Older builds:

Usage

This assumes that you have referenced the three DLL’s in the archive above within your project and have put the following using statements in your class:

using Newbtech.TwitterAPI;
using Newbtech.TwitterAPI.Objects; 

Most of the methods returns back generic lists of objects that you can easily reference. As an example, if you wish to get a list of your friends (people you follow):

TwitterAPI.Interface api = new Interface(USERNAME, PASSWORD);
Friends friends = api.GetFriends();

Then to list out all your friends, you would simply go through the friends list and access each user:

foreach (UserDetails user in friends.FriendsList)
{
Console.WriteLine(user.ScreenName);
}

I will be adding more detailed documentation later. Most of the functionality should be pretty much self-explanatory. I also include the source XML for each object as a public property just in case you wish to traverse through them to get any additional information.

As an example, the UserDetails class (which stores the information about a user) contains the following:

public XmlElement  SourceXml { get; set; }

public string Id { get; set; }
public string Name { get; set; }
public string ScreenName { get; set; }
public string Location { get; set; }
public string Description { get; set; }
public string ProfileImageUrl { get; set; }
public string Url { get; set; }
public TriState Protected { get; set; }

public long FollowerCount { get; set; }
public long FriendsCount { get; set; }
public long FavoritesCount { get; set; }
public long StatusCount { get; set; }
public TriState IsFollowing { get; set; } 

Features to come..

  • EXCEPTION HANDLING (yes, there isn’t much there yet!)
  • Commenting on the code ;-)
  • URL Shortening Service  – done 1.0.01
  • Relative Time
  • Json support
  • OAuth Authentication and workflow
  • etc etc.

License

You are welcome to use the DLL’s as they are. However, you are not allowed to disassemble the libraries without prior consent. You may not use these DLL’s for any commercial application without prior consent. All code within these DLL’s remain the property of Newbtech.

A fuller license agreement will be coming towards final release.

Comments (19)
  • Avatar

    Josh Jun 30 2009 - 6:35 pm Reply

    Do you plan to add search anytime soon?

  • Avatar

    dee Jul 1 2009 - 1:11 am Reply

    once I come back from vacation.. :-)

  • Avatar

    Josh Jul 16 2009 - 8:41 am Reply

    Are you back from vacation yet?

  • Avatar

    Ryan Jul 23 2009 - 8:28 pm Reply

    @Josh: Don’t bother. This will never be complete. It’s pretty obvious.

    Do Google for “Twitter C# class” and you’ll get lots of other options to get your job done.

    I waited quite a while for this class but I’m on a deadline. Nice effort but no point if it is not followed through!

  • Avatar

    dee Jul 24 2009 - 9:04 am Reply

    @Ryan, I did say i had to go on vacation and will continue once I’m back. And this is a very early release.

    If you saw the build list, you’d have noticed a release going out every couple of days.

    I don’t have internet access where I went (much less power and water!).

    I got back yesterday and will continue to work on this. This hasn’t been released on any published website apart from mine due to friends wanting this class.

  • Avatar

    Josh Aug 13 2009 - 7:14 am Reply

    Glad to see you have started working on it again. Keep up the good work.

  • Avatar

    dee Aug 13 2009 - 9:35 am Reply

    @Josh, no worries mate. I’ve just about got my Json and Atom helper classes set up as searching uses them instead of straight XML. Once its all tested, i’ll do another release.

  • Avatar

    Josh Aug 13 2009 - 9:43 am Reply

    Cool. Can’t wait.

  • Avatar

    dee Aug 13 2009 - 4:34 pm Reply

    @Josh, release 1.0.0.3 that has your search capability in it. I haven’t completely tested it yet, but its a start me thinks :)

    -dee

  • Avatar

    Josh Aug 14 2009 - 5:47 pm Reply

    Search is working great. Keep up the good work.

  • Avatar

    dee Aug 14 2009 - 6:10 pm Reply

    @Josh, good to hear mate. Let me know if there is anything else you need in the wrapper. In the meantime, I need to get authorisation and json working lol

    -dee.

  • Avatar

    Josh Aug 17 2009 - 3:19 pm Reply

    When you mention authorization, does this mean that requests will be charged to the user account instead of IPAddress?

  • Avatar

    dee Aug 17 2009 - 4:54 pm Reply

    requests should come through to the user account and not necessarily the ip address Josh…

    Currently, the GetRateLimitStatus() method checks the user account (and not the IP Address). Next release, I’ll overload it to allow you to specify which rate limit to check so that you can see for yourself which limit is being affected.

    -dee

  • Avatar

    Josh Aug 21 2009 - 10:06 am Reply

    Ok, I don’t know if this is some problem but I have 2 twitter accounts, and it doesn’t matter if i use one and then the other or just one for this but it gives me 417 errors. (The remote server returned an error: (417) Expectation Failed.)

    Interface Twit = new Interface(“AccountName”, “AccountPassword”);
    Followers TFollowers = Twit.GetFollowers();
    Twit.SendTweet(“testing”);

    I don’t know what causes this, but it sure gets annoying when I’M trying to search and respond to the tweets I want to.

  • Avatar

    dee Aug 21 2009 - 11:11 am Reply

    try including the following configuration in your app.config file:

    code

    Looks like some proxies out there may not like the expect100continue setting..

    See if that helps.
    Dee

  • Avatar

    Ron Oct 18 2009 - 8:58 am Reply

    hello,

    Is there an option to receive a list of followers – for some user ?
    (not my followers, other user – which I don’t have his password, only username)

    Thanks,
    Ron

  • Avatar

    dee Oct 18 2009 - 12:27 pm Reply

    @Ron,

    At this point in time, I have not included that functionality as it may be open to data mining/abuse.

    -dee-

  • Avatar

    Ron Oct 18 2009 - 11:19 pm Reply

    There is some Android-Twitter-Account with few hundreds of followers.
    I would like to follow only few from that followers list,
    since this is my Interest subject.

    So, I need the account followers list (as a collection),
    and from that collection, choose who to follow.
    (according to my logic)

    This is the reason that I need a user followers-List.

    Is it possible to implement ?
    Is there a twitter api for that ?
    (I’m new to the twitter api)

    Thanks again,
    Ron

  • Avatar

    dee Oct 19 2009 - 3:16 pm Reply

    Hi Ron,

    I’ve updated the API to version 1.0.0.4 that should implement what you need. I’ve published two new methods there, to firstly return back a list of follower id’s. And then for each id, you can retrieve each user’s details…

    That should meet your requirements.

    Be aware though: The retrieval list will try and return all the followers for a user and it can time out for large user sets.

    -dee-

Leave a reply

Name (required)

Website