First of all, I am able to successfully authenticate using Oauth. I am using Padraic\'s tutorial found here: http://blog.astrumfutura.com/archives/411-Writing-A-Simple-Twitter-C
We've done almost exactly this for Twitgoo.com (runnining full zend framework and twitter oauth login integration).
To generalize, we created two Zend_Auth_Identity
models - one for password login one for oauth login. (actually 3 where 1 is 'anon' and fails all Zend_Auth
). The identity holds the username and our local userid at minimum - for oauth it holds the Zend_Oauth_Token
, for password it holds the password (we never store it). These identity models are what the Zend_Auth_Adapter
for twitter returns, and what we pass to our Zend_Service_Twitter
extension.
our twitter then takes in a Identity model, and handles setting up twitter for it.
class Tg_Service_Twitter extends Zend_Service_Twitter {
public function __construct(Tg_Auth_Identity $login) {
if ($login instanceof Tg_Auth_Identity_Password) {
$password = $login->getPassword();
} else if ($login instanceof Tg_Auth_Identity_Oauth) {
$password = null;
$httpClient = $login->getOauthToken()
->getHttpClient(Tg_Service_Twitter_Helper::getOauthOptions());
self::setHttpClient($httpClient);
} else {
throw new Exception('not done yet');
}
$username = $login->getUsername();
self::setupHttpClient();
parent::__construct($username, $password);
if ($login instanceof Tg_Auth_Identity_Oauth) {
//makes it skip basic auth
$this->_authInitialized = true;
}
}
The $username is required to be set from the login (which twitter gives back to you during getting access token) by some of the Service_Twitter functions.
I can add more specifics if needed.