diff options
author | zottel <github@zottel.net> | 2014-02-19 08:30:14 +0100 |
---|---|---|
committer | zottel <github@zottel.net> | 2014-02-19 08:30:14 +0100 |
commit | 79d3dae7fa80df6ea6914807bcde4d8b8c390361 (patch) | |
tree | 96327bd990038c66f0e644c505522cb424a1bbd0 /library/openid/example-google.php | |
parent | 2bca2199112625593eb412584e17e874e71ca913 (diff) | |
parent | 24d119b8c4e94ed130577e4e4a8d17ea13c406ac (diff) | |
download | volse-hubzilla-79d3dae7fa80df6ea6914807bcde4d8b8c390361.tar.gz volse-hubzilla-79d3dae7fa80df6ea6914807bcde4d8b8c390361.tar.bz2 volse-hubzilla-79d3dae7fa80df6ea6914807bcde4d8b8c390361.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'library/openid/example-google.php')
-rw-r--r-- | library/openid/example-google.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/library/openid/example-google.php b/library/openid/example-google.php new file mode 100644 index 000000000..f23f2cc48 --- /dev/null +++ b/library/openid/example-google.php @@ -0,0 +1,24 @@ +<?php +# Logging in with Google accounts requires setting special identity, so this example shows how to do it. +require 'openid.php'; +try { + # Change 'localhost' to your domain name. + $openid = new LightOpenID('localhost'); + if(!$openid->mode) { + if(isset($_GET['login'])) { + $openid->identity = 'https://www.google.com/accounts/o8/id'; + header('Location: ' . $openid->authUrl()); + } +?> +<form action="?login" method="post"> + <button>Login with Google</button> +</form> +<?php + } elseif($openid->mode == 'cancel') { + echo 'User has canceled authentication!'; + } else { + echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.'; + } +} catch(ErrorException $e) { + echo $e->getMessage(); +} |