views:

142

answers:

1

I have sucessfully connected to twitter using Zend_Oauth_Consumer and got an access token, however when i try to use this access token i am getting an error.

This is the code:

$token = unserialize($twsession->access_token); # would be in DB
$twitter = new Zend_Service_Twitter(array(
    'username' => $token->screen_name,
    'accessToken' => $token
));
$response = $twitter->account->verifyCredentials();

This outputs:

Zend_Rest_Client_Result Object (
    [_sxml:protected] => SimpleXMLElement Object
        (
            [request] => /1/account/verify_credentials.xml
            [error] => Incorrect signature
        )

    [_errstr:protected] =>  )

I assume the code is actually correct, its hard to tell as the examples on the ZF site are incomplete.

FWIW i am using Zend Framework 1.10.8

+3  A: 

some fields were missing:

$token = unserialize($twsession->access_token); # would be in DB
$twitter = new Zend_Service_Twitter(array(
    'username' => $token->screen_name,
    'accessToken' => $token
));
$response = $twitter->account->verifyCredentials();

should be:

$token = unserialize($twsession->access_token); # would be in DB
$twitter = new Zend_Service_Twitter(array(
     'username' => $token->screen_name,
     'accessToken' => $token,
     'consumerKey' => YOUR_APP_CONSUMER_KEY,
     'consumerSecret' => YOUR_APP_CONSUMER_SECRET,
     'callbackUrl' => YOUR_CALLBACK_URL
 ));
$response = $twitter->account->verifyCredentials();

To confirm, for a valid signature you need all the same fields that you are using with Zend_Oauth_Consumer

seengee