Blog Posts

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"

Related Entries:
- rss2twi.php - Post your RSS feeds to Twitter with OAuth
- Hands on Twitter Applications with two real life examples
- The Real Time Web explained with a Real World Example

About the author

Comments [6]

Martin Fjordvald, 06.07.2009 21:39 CET

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!)

Chregu, 07.07.2009 06:15 CET

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 :)

Matthew Weier O'Phinney, 07.07.2009 12:38 CET

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

Chregu, 07.07.2009 13:18 CET

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..

Eran, 07.07.2009 15:58 CET

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

Chregu, 07.07.2009 16:01 CET

Ah, I forgot to tell that. It's the pecl extension from
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.

Add a comment

Your email adress will never be published. Comment spam will be deleted!