Single User OAuth using Zend Framework’s Twitter Service Class

Michelangelo van Dam wrote a neat little article to help with single user Twitter access.  What that means is that you can set up a Twitter application and then start tweeting without having to use a username and password.  Michelangelo did it in the context of a Zend Framework MVC application and so this blog post is only about doing what he did using the Twitter service as a library instead of the whole kit ‘n kiboodle.  Basically, here’s your code.

$config = array(
  'username' => 'kpschrade',
  'consumerKey' => 'CONSUMER_KEY',
  'consumerSecret' => 'CONSUMER_SECRET',
  Zend_Oauth_Token_Access::TOKEN_PARAM_KEY => 'TOKEN',
  Zend_Oauth_Token_Access::TOKEN_SECRET_PARAM_KEY => 'SECRET'
$accessToken = new Zend_Oauth_Token_Access();
$twitter = new Zend_Service_Twitter();

$result = $twitter->account->verifyCredentials();

if (isset($result->screen_name)) {
echo 'verified';
} else {
echo 'not verified';

3 Thoughts to “Single User OAuth using Zend Framework’s Twitter Service Class”

Leave a Reply

Your email address will not be published.