20 Feb 2007

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 (my older version of RegexBuddy -- best damn Regex tool in the universe -- and PHP weren't getting along) but I've since updated RegexBuddy to its latest version and added a new method call to TwitAPI called getDirectMessages.

It returns an array of objects (or an XML doc, depending on your method of access) with the following properties for each direct message:

  • messsageID: ID of the message.
  • senderUserName: User name of user who sent the message.
  • senderUserId: User ID of the user who sent the message.
  • senderProfileImageName: Name of the user's profile image (untested with users without image names -- don't rely heavily on this, I might remove it.)
  • message: The actual text of the direct message.
  • sent: When the message was sent (may be in the "X minutes ago" format or a timestamp depending on how it is returned by Twitter.)

Usage instructions:

JSON

http://aralbalkan.com/twitapi/json.php/Twitter.getDirectMessages/userName/passWord

XML

http://aralbalkan.com/twitapi/get_direct_messages_xml.php?user=userName&pass=passWord

Flash Remoting

Check out the AMFPHP service browser.

Add Your Comment

Spam Protection by WP-SpamFree

A new method for TwitAPI: getDirectMessages

  1. The API seems to have broken, either that or no one has any friends anymore.

    I played around with an XSLT to parse out the friends list, except when I ran it with the W3C XSLT service it broke. Turns out that if you’re not logged in to twitter, it doesn’t write out an opening tag in its header, but does write the closing tag, totally screwing up the dom!

    Thom Shannon
  2. [...] Thom alerted me yesterday (thanks, man) that the getFriends() method in the TwitAPI stopped working. [...]

    TwitAPI Update at Aral Balkan
  3. [...] 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. [...]

    A Yahoo! Pipe for Twitter at Aral Balkan