Skip to content

Instantly share code, notes, and snippets.

@chrisvogt
Last active December 12, 2015 08:49
Show Gist options
  • Save chrisvogt/4747204 to your computer and use it in GitHub Desktop.
Save chrisvogt/4747204 to your computer and use it in GitHub Desktop.
Interact with PAE SSO API and frame the scheduling system.
<?php
/**
* Request SSO token from Pan Am Education.
*
* https://panameducation.com/app/sso/token?api_login=__API-LOGIN__&api_password=__API-PASSWORD__&email=__STUDENT-EMAIL__
*/
## Set the query string values
$values = array(
'api_login' => $pae['api_login'],
'api_password' => $pae['api_password'],
'email' => $pae['email']
);
## Set the web API URL then build the query string
$ssoUrl = 'https://panameducation.com/app/sso/token';
$queryString = http_build_query( $values, '', '&' );
## Setup cURL
$ch = curl_init( $ssoUrl );
curl_setopt( $ch, CURLOPT_HEADER, 0 ); // disable header info from response
curl_setopt( $ch, CURLOPT_POSTFIELDS, $queryString ); // send along our query string
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, TRUE ); // verify the peer's certificate
## Fire off the request
ob_start();
$json = curl_exec( $ch ); // return response as json
ob_end_clean();
curl_close($ch);
unset($ch);
## API response; Tally-ho!
$resp = json_decode( $json );
## Extract the token from the response
$token = (string) $resp->result->token;
?>
<iframe id="HaFrame" src="https://panameducation.com/app/sso/ha_login?email=<?php echo $values['email']; ?>&amp;token=<?php echo $token; ?>&amp;mine=0" frameborder="1" width="100%" height="700" class="span12" name="content" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment