Twitter API trick: use standard update method for direct messagesPosted by Matt Thommes on December 23, 2008 | Post type: Gain If you utilize the Twitter API, it may be refreshing to know that you can save some development time when working with direct messages. The Twitter API provides various direct message methods, including one called "new", which sends a user a new direct message. The URL for the
This contrasts the standard "update" method URL (for public status updates), which looks like this:
Rather than building your application around these two separate, distinct URL's, you can choose to use only the "update" method, even for sending direct messages. Just prepend the "update" method call's text (the actual Twitter status update) with Even though the "update" method is not mentioned as an official way to send a direct message, it still works. The magic occurs on Twitter's end, where the update is properly parsed to check for This is a smart feature of the API, because they made it work just like the standard web interface works. It's funny, though - I can't find any mention of this capability in the API documentation. Nothing should be assumed, especially something that saves developers time. Interface logicDepending on how your application's interface is set up, it may be easier to just use the official direct message method. But you should at least inform your users that the alternate, "shorthand" approach is available. About the author(s)Matt Thommes is an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from a suburb of Chicago. Never one to conform, Matt intends to promote the effect the web has on our lives, in an effort to intensify, instruct, and clarify all that is happening around us. Comments
|
Quick Link to this postTTIP.me/2092 |