aboutsummaryrefslogtreecommitdiffstats
path: root/library/openid/example-google.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-02-17 18:50:24 -0800
committerfriendica <info@friendica.com>2014-02-17 18:50:24 -0800
commit7fc292831cfc86cf818c3fb71596ef8acb01f689 (patch)
treefe74559ad45047f1c055152007973d0ae1987967 /library/openid/example-google.php
parentd3120264cb99b8c87ecce01795bbc96265028b47 (diff)
downloadvolse-hubzilla-7fc292831cfc86cf818c3fb71596ef8acb01f689.tar.gz
volse-hubzilla-7fc292831cfc86cf818c3fb71596ef8acb01f689.tar.bz2
volse-hubzilla-7fc292831cfc86cf818c3fb71596ef8acb01f689.zip
update openid for snakebite
Diffstat (limited to 'library/openid/example-google.php')
-rw-r--r--library/openid/example-google.php24
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();
+}