Wednesday, November 09, 2011

Symfony2 FOSTwitterBundle TwitterProvider

Symfony2 and Twittter

If you are trying to integrate Symfony2 with Twitter, you're probably trying to install FOSTwitterBundle, and you may have faced two problems, one is that you can't create a user session after you login with Twitter and the other one is that there is no TwitterProvider class available as example in the instructions.

To help you with the second one here is a TwitterProvider class I made based on FacabookProvider.php

To solve the authentication problem on Symfony what I found is that Twitter anywhere only works at client level, so I decided to create a custom login button and built the authorization URL.

Controller action:

Twig template:

Then after the user authenticates with Twitter, the custom TwitterProvider can get the authentication tokens from the session and authenticate the user in Symfony.


Anonymous said...

Can you send a PR with updates to the README with your tips?

Carlos Mafla said...

Sure, no problem

JohnC said...

Hola Carlos - soy Irlandes y dueno du una agencia de mercadeo digital en Cali con clientes en USA. vi tu perfil en elance. no tengo proyectos en symfony pero seria chevere conocer mas personas que trabajan no solo en web pero remotemente. no veo como contactarte. ...

yo: John Coffey
311 609 7986

saludos - john