$SPID_CREDENTIALS[VGS_Client::REDIRECT_URI] = "http://{$_SERVER['HTTP_HOST']}/examples/client_login"; $SPID_CREDENTIALS[VGS_Client::COOKIE] = false; // disable cookie support for SDK // Instantiate the SDK client $client = new VGS_Client($SPID_CREDENTIALS); $client->argSeparator = '&'; // When a logout redirect comes from SPiD, delete the local session if (isset($_GET['logout'])) { unset($_SESSION['sdk']); } // Code is part of the redirect back from SPiD, redirect to self to remove it from URL // since it may only be used once, and it has been used to create session if (isset($_GET['code'])) { // Get/Check if we have local session, creates ones if code GET param comes $_SESSION['sdk'] = $client->getSession(); header("Location: " . $client->getCurrentURI(array(), array('code', 'login', 'logout'))); exit; } ?> <!doctype html> <html> <head> <title>SPiD Client user login and authentication example</title> <meta charset="utf-8"> </head> <body> <h1>SPiD Client user login and authentication example</h1> <?php // May get credential errors if (isset($_GET['error'])) { echo '<h3 id="message" style="color:red">' . $_GET['error'] . '</h3>';
<?php require_once '../src/Client.php'; require_once 'config.php'; if (!$SPID_CREDENTIALS) { die('ERROR: You must configure $SPID_CREDENTIALS in config.php first!'); } $client = new VGS_Client($SPID_CREDENTIALS); if (isset($_GET['logout'])) { $client->deleteSession(); } $session = $client->getSession(); if ($session && isset($_GET['code'])) { header("Location: " . $client->getCurrentURI(array(), array('code'))); exit; } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <link href="css/prettify.css" type="text/css" rel="stylesheet" /> <link rel="stylesheet" href="css/default.css" /> <script src="js/jquery-1.5.2.min.js"></script> <script src="js/jquery.tmpl.js"></script> <script src="js/format-json.js"></script> <script src="js/global.js"></script> <script> VG.api.methods = <?php try { $res = $client->api('/endpoints');