TwitAPI: A Twitter API Extension

I just presented at BarcampLondon2 on a little API extension I've been working on as a hobby for Twitter called TwitAPI. I found the official Twitter API slightly limiting when playing around with Friend or Follower. Specifically, there isn't a way to get a list of someone's friends without actually having their login information. And there's no support for adding, removing, following and leaving friends. Well, there wasn't, until TwitAPI :)

Basically, TwitAPI does the ugly work behind the scenes and gives you a simple API for accessing these features. Thanks to Amfphp, you get a Flash Remoting and JSON interface. And, for the getFriends call, I created an XML option as well.

Here are some brief docs if you want to start working with it right away (if anyone's going to do anything with it at BarcampLondon2, feel free to find me here.)

JSON endpoint:

http://aralbalkan.com/twitapi/json.php

Methods:

getFriends (userName)

Usage:

http://aralbalkan.com/twitapi/json.php/Twitter.getFriends/userName

Example:

http://aralbalkan.com/twitapi/json.php/Twitter.getFriends/aral

userName: User name of the user to get the friends list for. Returns an array of objects with id, userName, fullName, imageName, normalImageUrl properties.

You can also access the friends list in XML (see below).

addFriend (friendUserId, friendUserName, yourUserName, yourPassWord)

Usage:

http://aralbalkan.com/twitapi/json.php/Twitter.addFriend/friendUserId/friendUserName/yourUserName/yourPassWord

Returns:

True or false, depending on whether the user was successfully added.

The removeFriend, followFriend and leaveFriend methods work in exactly the same way and take exactly the same arguments.

In case there's a worry about security: Yes, you're passing your Twitter username and password in plain text in the GET string but your username and password get passed in plain text via basic authentication in the header with Twitter in any case so it's no less or more secure than Twitter in general (which is basic authentication over http so it's not secure.)

XML service

The getFriends method has an XML service too:

http://aralbalkan.com/twitapi/get_friends_xml.php

Usage:

http://aralbalkan.com/twitapi/get_friends_xml.php?user=userName

Example:

http://aralbalkan.com/twitapi/get_friends_xml.php?user=aral

Flash Remoting gateway

There is also a Flash Remoting gateway that you can use with the same methods. Details are in the AMFPHP Service Browser (ignore the username and password text inputs in the interface -- that's for testing basic authentication).

Creative Commons LicenseThe TwitAPI: A Twitter API Extension article by Aral Balkan, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial 2.0 UK: England License.

9 Responses to “TwitAPI: A Twitter API Extension”


  1. 1 josh russell

    so is that twitter-pee or twit-appy?

    the pronunciation of course :)

  2. 2 Mark Ng

    Hi, I was at your twitapi presentation at barcamp, which was fun !

    I recall you making the code available for download for people to play with, but don’t remember where - did you make a tarball available somewhere, or did you mean for us to make calls to the API running on your server ?

  3. 3 aral

    Hi Mark,

    Glad you enjoyed the session. Feel free to use the API from my server. Although I believe that Twitter changed something and broke the calls. (Not sure whether that was intentional or not on their part.)

    I’m going to look into it to see if it was intentional or not. If they’re intentionally blocking the API then I don’t really feel motivated to fight them on it. If not, I’ll post an update after I’ve fixed the API.

  1. 1 Simon Jobling (aka One Phat DJ) » Blog Archive » Tagged (2007.02.19)
  2. 2 A new method for TwitAPI: getDirectMessages at Aral Balkan
  3. 3 TwitAPI Update at Aral Balkan
  4. 4 A Yahoo! Pipe for Twitter at Aral Balkan
  5. 5 JD on EP
  6. 6 #!/usr/bin/geek

Leave a Reply






Bad Behavior has blocked 0 access attempts in the last 7 days.