Below are two sample PHP scripts for setting up Visit Partner single sign-on (see Single sign-on). These scripts are provided only as examples and may not work as-is. If you have any questions regarding this implementation, the Visit and Poken by GES development team is ready and willing to advise you.
You need a shared key and event code to complete your script. See Shared key and event code for more information.
Example 1
- <?php
- $sharedKey = 'xxxxxx'; // shared key of organisation, see note below
- // Make sure parameters are specified in alphabetical order for correct calculation of hash
- $request = array(
- 'contactref' => 'yyyy', // reference to partner as set when importing them or via API
- 'expo' => 'zzzzzzz', // expo code from visit
- 'time' => time()
- );
- // create a hash from un-encoded query string and sign with pre-shared-key
- $hashSource = urldecode(http_build_query($request)) . $sharedKey;
- echo "HASH is taken from SHA256('" .$hashSource . "')<br/>";
- // checksum based on alphabetically ordered name/value pairs with appended sharedkey
- $request['check'] = hash('sha256', $hashSource);
- echo "<form action='https://account.n200.com/partner/loginauth' method='POST'>";
- foreach ($request as $key => $value) {
- echo "<input type='text' name='". $key ."' value='" . $value ."'/>";
- }
- echo "<input type='submit' value='Submit'/></form>";
Example 2
- <?php
- $sharedKey = 'xxxxx'; // shared key of organisation, see note below
- $request = array(
- 'contactref' => ‘yyyyyy’, // reference to partner as set when importing them or via API
- 'expo' => 'zzzzzzzzzz',
- 'time' => time()
- );
- // create a hash from un-encoded query string and sign with pre-shared-key
- $request['check'] = hash('sha256', urldecode(http_build_query($request)) . $sharedKey);
- $ch = curl_init('https://account.n200.com/partner/loginauth');
- curl_setopt_array($ch, array(
- CURLOPT_POST => true,
- CURLOPT_FOLLOWLOCATION => false,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_POSTFIELDS => http_build_query($request)
- ));
- curl_exec($ch);
- $info = curl_getinfo($ch);
- header('Location: '. $info['redirect_url']);
If Partners are added manually you will need to use the Partner Code as reference. This example below would replace lines 5-10 in Example 1 and lines 4-8 in Example2.
// Make sure parameters are specified in alphabetical order for correct calculation of hash$request = array( 'partner' => 'dfgoiui44', 'time' => time());
You can find your SharedKey at Organisation – Organisation Profile.
Comments
0 comments
Please sign in to leave a comment.