Skip to content

Commit

Permalink
added facebook example (non-functional yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-novakov committed Jul 9, 2013
1 parent 8b7be4c commit dd597a9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,3 +6,4 @@ composer.lock
public/config.php
public/google/config.php
public/github/config.php
public/facebook/config.php
19 changes: 19 additions & 0 deletions public/facebook/config.php.dist
@@ -0,0 +1,19 @@
<?php
return array(

'client_info' => array(
'client_id' => '<client ID>',
'redirect_uri' => '<redirect URI>',

'authorization_endpoint' => 'https://accounts.google.com/o/oauth2/auth',
'token_endpoint' => 'https://accounts.google.com/o/oauth2/token',
'user_info_endpoint' => 'https://www.googleapis.com/oauth2/v1/userinfo',

'authentication_info' => array(
'method' => 'client_secret_post',
'params' => array(
'client_secret' => '<client secret>'
)
)
)
);
30 changes: 30 additions & 0 deletions public/facebook/index.php
@@ -0,0 +1,30 @@
<?php
use InoOicClient\Flow\Basic;

require __DIR__ . '/../../init_autoload.php';

$config = require __DIR__ . '/config.php';

$flow = new Basic($config);

if (! isset($_GET['redirect'])) {

try {
$uri = $flow->getAuthorizationRequestUri('openid email profile');
_dump($uri);
printf("<pre>%s</pre><br>", $uri);
printf("<a href=\"%s\">Login</a>", $uri);
} catch (\Exception $e) {
_dump("$e");
printf("Exception during authorization URI creation: [%s] %s", get_class($e), $e->getMessage());
}
} else {

try {
$userInfo = $flow->process();
printf("<pre>%s</pre>", print_r($userInfo, true));
} catch (\Exception $e) {
_dump("$e");
printf("Exception during user authentication: [%s] %s", get_class($e), $e->getMessage());
}
}

0 comments on commit dd597a9

Please sign in to comment.