Newbtech .net 3.5/C# Twitter API Wrapper

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.

19 Comments to Newbtech .net 3.5/C# Twitter API Wrapper

Do you plan to add search anytime soon?


once I come back from vacation.. :-)


Are you back from vacation yet?


@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!


@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.


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


@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.


Cool. Can’t wait.


@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


Search is working great. Keep up the good work.


@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.


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


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


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.


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


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


@Ron,

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

-dee-


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


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 comment

affiliate_link
PageRank