The Twitter OAuth PHP Class Gets Even Better
December 14th, 2009Or perhaps simpler?.. Together with the Twitter API itself, the TwitterOAuth PHP class (the one by Abraham Williams) is being updated too! According to GitHub the latest changeset was commited on December 3rd so yeah, I tried to take a look at what’s going on there a few days ago and was quite disapointed. Disappointed with the fact that all my previous code was broken without giving any reason.
Just like everybody else, I never read the readme or other documentation files so I dug straight into the class code and examples. Soon after I realized that the new changes were not that bad, so instead of the usual 5 lines of code, I shortened it up to only one. I stopped worrying about parsing XML or JSON, converting them to objects, and I stopped typing in the full address for Twitter API calls. Abraham did all that for us, so all we have left is:
1 2 3 | $credentials = $oauth->get("account/verify_credentials"); if ($oauth->http_code == 200) echo "Hey there, {$credentials->screen_name}!"; |
I’m not going to publish all the new features and stuff (read about them at GitHub), but hey, this is quite sweet isn’t it? The only drawback was having to rewrite some parts of the code I wrote for the past few months (the Twitter Robots stuff), but I guess that’s partly my bad as it’s not as organized as it should be. That’s the main reason why I’m not publishing the whole code here yet, have a lot of cleaning up to do ;)
Meanwhile you may take a look at this buddy: @web2feed. I turned off the auto-replies because they were getting quite annoying, and I’ve added a couple of feeds to the big list, oh and it’s DM controlled too!
Related posts:
- Twitter API: PIN-based OAuth Using PHP
- Twitter API: Moving From Basic Auth to OAuth
- The Importance of Using Twitter API via OAuth
- Automated Serverside Tweeting Using OAuth
- PHP: The User Class Snippet
Tagged: api, oauth, php, twitter, twitterapi
Shortlink: http://kovshenin.com/1688














Glad you like the new changes. The lack of backwards compatibility does suck but I feel the slimmed down version is worth it.
I’ve been build a list of applications using TwitterOAuth and would like to add any you have.
http://wiki.github.com/abraham/twitteroauth/links
Heh, that page mentions me 4 times, thanks so much buddy! I’m working on a new and massive “Twitter for WordPress” plugin, perhaps that’ll be good enough to make it to the Projects list, right below Foller.me ;)
Cheers!