Twitter API shut down Basic Auth on August 31. I was a big fan of the Arc90 Twitter library, but its no longer usable because of the shutdown. Even before the shutdown, I’d been using Abraham’s twitterOAuth for Twitter Signin integration with my websites. Its a nice library that hides the OAuth security aspects from developers. But after having used Arc90 library in all my projects, migrating the code to another library was costly and time consuming.
So, I merged both the libraries. I enabled OAuth in Arc90 library by making some internal calls to twitterOAuth library. This way, I could continue using Arc90 library in my projects just by porting the new library and adding few lines of code to pass access tokens to the library object.
I’ve published the library in GitHub at http://github.com/yemkay/arc90-twitteroauth, which is also my first Open Source contribution.
Here is a code snippet that retrieves Twitter home timeline using the new library:
<?phprequire_once("lib/Arc90/Service/Twitter.php");$twitter = new Arc90_Service_Twitter(); //Pass consumer key, secret of Oauth app and user's access token, secret $twitter->useOAuth('OAUTH_CONSUMER_KEY', 'OAUTH_CONSUMER_SECRET', 'USER_TOKEN', 'USER_SECRET');//Get tweets from user's timeline $response = $this->twitter->getFriendsTimeline('json', array('count' => 200, 'page' => $page));echo ('HTTP code: '.$response->getHttpCode()); if (!$response->isError()) { $messages = $response->getJsonData(); echo 'Found '.count($messages).' new tweets'; /* GO AHEAD AND PROCESS TWEETS */ } else { echo 'Error description: '.$response->getData(); } ?>