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 OneID sign-in is a two-step process. On the page where you want the sign-in button, you must include a script tag and decide where to place the 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("oneid_demo/login.php") // This inserts the sign-in button ?>
In the OneID_Button function, pass in the the target destination that you host for logging in or registering a new user on your site. These should be PHP destinations on your website.
oneid_demo/login.php is a file that handles the response when the user clicks the OneID button. The code is:
<?php require ("oneid.php"); $attrs = OneID_Response(); // This function handles validation of // the response from OneID and returns an // array of attributes for the user. // Local code to "log in" the user session_start(); $_SESSION['email'] = $attrs['attr']["personal_info"]['email']; // Return the response echo OneID_Redirect('account.php'); // Redirect the user after a successful local authentication
account.php is the destination where you want the client’s browser to be sent after signing in successfully.