Skip to content

Instantly share code, notes, and snippets.

@alexbilbie
Created October 14, 2012 16:16
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexbilbie/3889060 to your computer and use it in GitHub Desktop.
Save alexbilbie/3889060 to your computer and use it in GitHub Desktop.
OAuth2 client example
{
"require": {
"lncd/oauth2-facebook": "*",
"slim/slim": "2.*"
},
"minimum-stability": "dev"
}
<?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