In a previous article, we found out about Guzzle and how it can aid us in the task of establishing communication with third party API’s over HTTP. We used it to get the output of a random number generator and basic interaction with Github’s API. It also offers a series of ‘subscribers’, log-subscriber being one of them and showed us how easy it was to integrate monolog into it.
While interacting with Github’s API we discovered that it supports basic authentication (sending plain username/password). But what if the API we want to use just offers OAUTH authentication?
Guzzle’s Oauth
Implementing OAUTH from scratch can be a hard and time consuming task, and would be like reinventing the wheel… You could grab a third party library to deal with OAUTH requests, but why do that when guzzle has its own OAUTH subscriber? Yay!
First of all, I have to make you aware that Guzzle has dropped support for PHP 5.3, so you’ll need PHP 5.4 to follow this exercise. The installation instructions from the previous article changed a little bit, yet composer makes our lives a lot easier.
Our goal is to interact with the Twitter API and get our own timeline for which ever purpose we need. We’ll begin with our composer.json file:
Continue reading %Using Guzzle with Twitter via Oauth%
more
{ 0 comments... » Using Guzzle with Twitter via Oauth read them below or add one }
Post a Comment