Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend Framework Twitter OAuth + Token

Hi I just finished coding my OAuth w/ zend framework. I retrieve my Token. The query string returned has user id,username,secret,token

I try the following

$twitter = new Zend_Service_Twitter(array(
'username' => $auth['username'],
'accessToken' => $auth['token']
));
$rsp = $twitter->status->update('My Tweet');

But I cant successfully sign in? My question is do I pass the full accessToken that contains all values? I tried that also but I still cant get an error that i did not sign in successfully

like image 225
slik Avatar asked Oct 14 '10 04:10

slik


2 Answers

You need to pass a proper options array which includes your consumer key, secret and user's tokens. The token must be an Oauth Token Access object.

$token = new Zend_Oauth_Token_Access();
$token->setToken($userToken)->setTokenSecret($userSecret);

$options = array(
    'accessToken'    => $token,
    'consumerKey'    => $appConsumerKey,
    'consumerSecret' => $appConsumerSecret);

$twitter = new Zend_Service_Twitter($options);
$response = $twitter->status->update("My Message!");

The above should work assuming you have all the tokens required! All of these tokens are available on Twitter's dev page in your own personal application settings.

like image 83
Darryl E. Clarke Avatar answered Nov 12 '22 01:11

Darryl E. Clarke


For OAuth API access (in general, not just twitter) you provide the access token and the access token secret to gain access. There is no "sign in" at that point because that has already happened when you authorized using the request token in order to get the access token and access token secret.

I find the "Twitter Three-legged OAuth Example" here to be helpful: http://github.com/simplegeo/python-oauth2

like image 26
kanaka Avatar answered Nov 11 '22 23:11

kanaka