A Twitter Adapter for Zend_Auth

From time to time I write some little scripts for my own needs or just to test out new stuff. And I realised, that I blog about it way too little. So here I start with my latest addition: Zend_Auth_Adapter_Twitter

The occasional webapp needs a login for managing users. Doing that by yourself is 1) cumbersome and moreover 2) very outdated (who likes to remember login/password for each and every site). As I was playing with oauth for Twitter anyway lately, I came up with a Zend_Auth Adapter for Twitter. The integration was pretty easy, but the code is very basic and rough. Nevertheless, it does the job and alongside the Openid Adapter I can offer a federated login for many people already. Now, someone should do a Zend_Auth_Adapter_Google :)

The code and a super simple example can be found in our SVN repository, it also needs the Zend_Auth_Result_Twitter class. And here’s the “Live Demo”

While options are great, only having a twitter login would be silly, a lot of people don’t actually have a twitter account. At the sites I run I think less than 1% of my visitors actually have a twitter account.

So you still have to offer you own login system. (Though you can steal an already developed one!)

Sure you have to watch your target audiance :) But if there would be an Adapter for Google, maybe one for Facebook, one for Yahoo and together with the already mentioned OpenID one, you could cover a looot without having to do your own.

And if you do a twitter related app, you have 100% coverage with this adapter :)

Any chance I can talk you into contributing this to ZF? :)

Matthew: Can I talk you into just take the code and do whatever you want with it? :) ’cause I’m not a big fan of the Zend CLA thingie..

Thanks Christian, I was just looking for something like this. Where does the OAuth class you instance in your adapter comes from?

Ah, I forgot to tell that. It’s the pecl extension from http://pecl.php.net/package/oauth
I was too lazy to look for a extension-independent solution, but maybe one can make it work with Zend_Oauth

By the way, I will change the getIdentity() a little bit, now it returns an array, which is not consistent to the other Adapters.