Skip to content

Social authentication classes to use with Silex: Twitter, Facebook,... You could use it with whatever, but you will have to change the session provider.

License

Notifications You must be signed in to change notification settings

topikito/Silex-SocialFactory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Silex-SocialFactory

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.

Dependencies

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/

Examples

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.

Twitter

Login

$twitterObject = SocialFactory::createTwitter($app);
$twitterObject->setConsumerKey($twitterData['key']);
$twitterObject->setConsumerSecret($twitterData['secret']);
$twitterObject->setCallbackURL($config['application.host'] . 'login/twitter/auth/');

$redirectUrl = $twitterObject->login();

Auth

$twitterObject = SocialFactory::createTwitter($app);
$twitterObject->setConsumerKey($twitterData['key']);
$twitterObject->setConsumerSecret($twitterData['secret']);
$twitterObject->setOAuthToken($oAuthToken);
$twitterObject->setOAuthVerifier($oAuthVerifier);

$result = $twitterObject->auth();

Facebook

Login

Returns the social ID of the user.
$facebookObject = SocialFactory::createFacebook($app);
$facebookObject
	->setAppId($config['facebook.appid'])
	->setSecret($config['facebook.secret']);

$result = $facebookObject->login();

Auth

Returns the data of the user.
$facebookObject = SocialFactory::createFacebook($app);
$facebookObject
	->setAppId($config['facebook.appid'])
	->setSecret($config['facebook.secret']);

$result = $facebookObject->auth();

About

Social authentication classes to use with Silex: Twitter, Facebook,... You could use it with whatever, but you will have to change the session provider.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages