3

Basically I want to use the Twitter Users Lookup (REST API) method, this: http://apiwiki.twitter.com/w/page/24142947/Twitter-REST-API-Method:-users-lookup

but just for one request, so more less manually.

When the API supported basic authentication I could just plug in my username/password and gather information about the people tweeting on a given subject/search (as to how many followers they have, location, etc - mainly for reach/ROI purposes). I would just request the XML, format it and shove it into an excel file to play with.

Since Twitter no longer supports basic authentication with this method is there another way I can manually request this information, or do I actually need to setup oAuth?

Is there another option that's easier?

2 Answers 2

1

I use LINQPad for all of my Twitter spelunking; it's simply one of the best tools I've used for exercising any code. It's a free utility (you only have to pay if you want statement autocompletion and some other nifty features, but you don't need them). If you don't run Windows then this won't be of much use to you, but if you have a Windows box you can use, then the ability to use the Dump() method provide by LINQPad is just a massive timesaver.

Using LINQPad

First you have to register an application with Twitter. Adam has a very nice writeup on setting up your application on dev.twitter.com in his answer.

Once you have your OAuth tokens, download and install LINQPad and the .NET Framework 4.0 (if you don't already have it.)

Next grab Twitterizer, which is a great .NET Twitter library. I'm using version 2.3.1 for this example. Unpack the ZIP file to a location you can reference later. Now we can get started.

Start LINQPad, click on the Query 1 window, and change the Language to C# Statements.

Next press F4 to open the Query Properties. On the Additional References tab click Browse... and find Twitterizer2.dll where you extracted it earlier.

Adding a reference to Twitterizer2.dll in LINQPad

Now, click on the Additional Namespace Imports tab and type Twitterizer into the window like so:

Adding a reference to Twitterizer in LINQPad

Now click OK, and we can write our query.

In the Query 1 window, enter the following code:

OAuthTokens tokens = new OAuthTokens();
tokens.ConsumerKey = "YourConsumerKey";
tokens.ConsumerSecret = "YourConsumerSecret";
tokens.AccessToken = "YourAccessToken";
tokens.AccessTokenSecret = "YourAccessSecret";

TwitterUser.Lookup(
  tokens, 
  new LookupUsersOptions { 
    ScreenNames={"arcain","dotnetdevbuzz"}, IncludeEntities=true 
  }
).Dump(); // the magic happens here!

Now hit F5 to execute the query, and off LINQPad goes to Twitter to fetch your results.

The results using Dump() are nicely formatted, and the entire object is rendered without having to reference anything explicitly, like so:

Results from calling Twitter using LINQPad and Twitterizer

You can then click Export Results to export to Excel, Word, or just HTML, although you may want to reference some of the object fields directly to target your report data.

Oh, and you can apply Dump() to just about anything, so it is a nice addition to any toolbox. Anyway, I hope you can make use of this as I find it a real time saver.


I finished the above, and then remembered the Twitter dev console, Twurl. Twurl is a bare-bones console that is available from the Apps tab on dev.twitter.com. It can be found by following a link on the right side of the page:

Link to the Twurl Console

Now, Twurl would be great if it wasn't broken, but it still is. So, the next best thing (if you still want a webby console alternative to LINQPad) would be using a free service like apigee.com which supports OAuth as well.

1
  • Thanks for that! Serendipitously one of your links led me to: app.apigee.com/console , which does essentially what I wanted, including oauth authentication! Very cool for meager API needs like mine.
    – Jane Panda
    Commented Feb 1, 2011 at 17:24
1

If you don't want to do any programming and just enter a URL in a browser, you can do this one user at a time with /users/show:

http://api.twitter.com/1/users/show.xml?screen_name=barackobama

This doesn't require any authentication. If you want to use /users/lookup to get multiple users at one time, you do have to write code that uses OAuth.

1
  • I was afraid of that; still that is useful that you can look up one user at a time (if a bit counterproductive on Twitter's part). Do you happen to have any info on how I could best implement a simple oAuth setup? I'd really prefer to use something entirely client sided, but I have places I could host a server side solution.
    – Jane Panda
    Commented Jan 31, 2011 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.