Blame view

common/components/nodge/lightopenid/example.php 1.02 KB
b0f143c3   Yarik   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  <?php
  require 'openid.php';
  try {
      # Change 'localhost' to your domain name.
      $openid = new LightOpenID('localhost');
      if(!$openid->mode) {
          if(isset($_POST['openid_identifier'])) {
              $openid->identity = $_POST['openid_identifier'];
              # The following two lines request email, full name, and a nickname
              # from the provider. Remove them if you don't need that data.
              $openid->required = array('contact/email');
              $openid->optional = array('namePerson', 'namePerson/friendly');
              header('Location: ' . $openid->authUrl());
          }
  ?>
  <form action="" method="post">
      OpenID: <input type="text" name="openid_identifier" /> <button>Submit</button>
  </form>
  <?php
      } elseif($openid->mode == 'cancel') {
          echo 'User has canceled authentication!';
      } else {
          echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
  	print_r($openid->getAttributes());
      }
  } catch(ErrorException $e) {
      echo $e->getMessage();
  }