Social authentication classes to use with Silex. You could use it with any framework or code, but you will have to change the session provider.
Even it's ment to act as a factory, I've added methods as createTwitter so I can hardcode the return type and this way use the autocomplete functionallity of IDEs.
For Twitter we use Abraham's OAuth class: https://github.com/abraham/twitteroauth/
For Facebook we use Facebook's official class: https://github.com/facebook/facebook-php-sdk/
Login function returns the social ID of the user. Auth functions returns ReturnObject which is an unified format for the basic info: social ID, email (if given), avatar and the metadata as an array.
$twitterObject = SocialFactory::createTwitter($app);
$twitterObject->setConsumerKey($twitterData['key']);
$twitterObject->setConsumerSecret($twitterData['secret']);
$twitterObject->setCallbackURL($config['application.host'] . 'login/twitter/auth/');
$redirectUrl = $twitterObject->login();
$twitterObject = SocialFactory::createTwitter($app);
$twitterObject->setConsumerKey($twitterData['key']);
$twitterObject->setConsumerSecret($twitterData['secret']);
$twitterObject->setOAuthToken($oAuthToken);
$twitterObject->setOAuthVerifier($oAuthVerifier);
$result = $twitterObject->auth();
$facebookObject = SocialFactory::createFacebook($app);
$facebookObject
->setAppId($config['facebook.appid'])
->setSecret($config['facebook.secret']);
$result = $facebookObject->login();
$facebookObject = SocialFactory::createFacebook($app);
$facebookObject
->setAppId($config['facebook.appid'])
->setSecret($config['facebook.secret']);
$result = $facebookObject->auth();