Created
October 14, 2012 16:16
-
-
Save alexbilbie/3889060 to your computer and use it in GitHub Desktop.
OAuth2 client example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"lncd/oauth2-facebook": "*", | |
"slim/slim": "2.*" | |
}, | |
"minimum-stability": "dev" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include_once('phperror.php'); | |
include_once('vendor/autoload.php'); | |
$app = new \Slim\Slim(array( | |
'mode' => 'development', | |
'debug' => true | |
)); | |
$app->get('/login', function () { | |
$fb = new FacebookIDP(array( | |
'clientId' => 'foobar', | |
'clientSecret' => 'foobar', | |
'redirectUri' => 'http://oauth-client-site.test/index.php/login' | |
)); | |
if ( ! isset($_GET['code'])) { | |
$fb->authorize(); | |
} else { | |
$token = $fb->getAccessToken($_GET['code']); | |
$user_details = $fb->getUserDetails($token); | |
print_r($user_details); | |
} | |
}); | |
$app->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment