The Twitter OAuth PHP Class Gets Even Better

Or 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:

$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!

10 thoughts on “The Twitter OAuth PHP Class Gets Even Better

  1. The Twitter OAuth PHP Class Gets Even Better | Coder Online

  2. Tweets that mention The Twitter OAuth PHP Class Gets Even Better --

    • 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 ;)


  3. uberVU - social comments

  4. Hey,

    I have been using TwitteroAuth class, one thing i am trying to do is query the REST api using the user's access token. I am using oAuthRequest() function to fetch the user's credential, it gives me not authorized error. However the method you used worked fine but I cannot understand why the other on didnt work. Can you please shed some light on how the actual process work??

Comments are closed.