[Ils-source] r1534 - trunk/webapp/examples
scribe at crosswire.org
scribe at crosswire.org
Wed Apr 26 11:27:29 MST 2017
Author: scribe
Date: 2017-04-26 11:27:28 -0700 (Wed, 26 Apr 2017)
New Revision: 1534
Added:
trunk/webapp/examples/testapilaunchcourse.php
Log:
Added example to show how to lauch a course for a user
Copied: trunk/webapp/examples/testapilaunchcourse.php (from rev 1531, trunk/webapp/examples/testapilaunch.php)
===================================================================
--- trunk/webapp/examples/testapilaunchcourse.php (rev 0)
+++ trunk/webapp/examples/testapilaunchcourse.php 2017-04-26 18:27:28 UTC (rev 1534)
@@ -0,0 +1,36 @@
+<?php
+require_once 'HTTP/Request2.php';
+
+$loginAPIURL = new HTTP_Request2('http://216.119.104.185:8081/api/session/login/index.jsp', HTTP_Request2::METHOD_POST);
+
+$launchAPIURL = 'http://216.119.104.185:8081/api/session/launch/index.jsp';
+$launchPoint = 'http://216.119.104.185:8081/aicc.jsp?courseid=1';
+
+$loginAPIURL->addPostParameter('ILSUSER', 'user1');
+$loginAPIURL->addPostParameter('ILSPASSWD', 'changeme');
+
+try {
+ $response = $loginAPIURL->send();
+ if (200 == $response->getStatus()) {
+ $loginToken = $response->getBody();
+ // check if we're a UUID
+ if (substr($loginToken, 8, 1) == '-' && substr($loginToken, 13, 1) == '-' && substr($loginToken, 18, 1) == '-') {
+ echo '
+<html><head>
+<meta http-equiv="Refresh" content="0;URL=' . $launchAPIURL . '?uuid=' . $loginToken . '&launchPoint=' . $launchPoint . '">
+</head></html>
+';
+ }
+ else {
+ echo 'Invalid Credentials (' . $loginToken . ')';
+ }
+ }
+ else {
+ echo 'Could not communicate with iLS (' . $response->getStatus() . ')';
+ }
+} catch (HTTP_Request2_Exception $e) {
+ echo 'Error: ' . $e->getMessage();
+}
+
+?>
+
More information about the Ils-source
mailing list