Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
OneID PHP SDK

This branch is 88 commits behind master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples/oneid_demo
.gitignore
README.markdown
oneid.php

README.markdown

About

This tutorial uses a small PHP library that implements the relevant calls to the OneID web services.

If you have any questions, join us on #OneID on Freenode.

Implementing

Implementing OneID sign-in is a three step process, one for each page on your server. On the page where you want the sign-in button, you include a script tag and place the login button. The PHP library has helper variables and functions to make this simple:

<?php require ("oneid.php"); ?>
<?php echo $oneid_script; // This inserts the script tag ?>
<?php echo OneID_Button("verify.php") // This inserts the sign-in button ?>

In the OneID_Button function, pass in the the target destination that you host for verifying the credentials provided by OneID and linking the OneID to the current user. These should be PHP destinations on your website.

verify.php is called by the OneID client during the authentication ceremony. The code is:

<?php require("oneid.php");

$response = OneID_Response(); 
// This function handles validation of
// the response from OneID and returns an 
// array of attributes for the user.

session_start();

if(OneID_IsSuccess($response)) {
    // here you do what you need to link the OneID with the current user.
    $_SESSION['email'] = $response['attr']['personal_info']['email'];
    $_SESSION['OneID'] = $response['uid'];
} else { 
// if it fails, clear whatever link may have been set previously
    unset($_SESSION['OneID']);
    unset($_SESSION['email']);
    $_SESSION=array_values($_SESSION);
} 

echo OneID_Redirect('account.php',$response);

// OneID_redirect will return JSON that will send the browser to the specified page and pass any errorcodes from authentication and verification back to the OneID client.

?>

account.php is the destination where you want the client’s browser to be sent after signing in successfully.

Something went wrong with that request. Please try again.