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).
The 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.
so is that twitter-pee or twit-appy?
the pronunciation of course :)
[...] TwitAPI: A Twitter API Extension at Aral Balkan [...]
[...] I was talking with Tom at BarCampLondon2 and he suggested that it would be useful to be able to get a list of direct messages for a given user. I was having issues with the Regex for doing this on the night (Regex Buddy and PHP weren’t getting along) but I’ve seen updated RegexBuddy to its latest version and added a new method call to TwitAPI called getDirectMessages. [...]
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 ?
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.
[...] Thom alerted me yesterday (thanks, man) that the getFriends() method in the TwitAPI stopped working. [...]
[...] I just published my first Yahoo! Pipe (oh big day, big day!) It adds a feature to the TwitAPI (and here, and here) that I’ve wanted for a while, which is the ability to get only those Twitter updates that have occurred since a certain time. [...]
SXSW Twitter…
SXSW Twitter: The South by Southwest conference has a SWF display of messages texted into the Twitter service. The interface makes sense to me — easier to understand the feel of a crowd like this than in a linear text stream — easy to picture this on…
75 Links That Rock Twitter! What are you doing?…
Damn, I love Twitter! I’ve even declared it a MySpace killer. Why? Simply because of its addictiveness and simplicity. Who wants all the garbage and crap advertised on MySpace anyway? This is how social networking should be, not a high……