Zend Framework Twitter OAuth + Token
Hi I just finished coding my OAuth w/ zend framework. I retrieve my Token. The query string r开发者_运维问答eturned 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
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.
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
Try this:
$twitter = new Zend_Service_Twitter( $auth['username'], $auth['token'])
The construction is not array.
Just a guess
精彩评论