Tech Blog

INN-Reach and Alma at the Colorado Alliance of Research Libraries

Prospector is the direct consortial borrowing [DCB] network in use at the Colorado Alliance of Research Libraries. The network utilizes the INN-Reach shared catalog system (by Innovative Interfaces Inc.). When implementing the integration between Alma and INN-Reach, the Alliance made use of the PHP script written by Ian Chan, Head of Library Technology Initiatives and Development at the California State University San Marcos (see

The University of Denver Libraries, an Alliance Member, worked closely with the Alliance to implement this integration.  Denver’s use of an additional NCIP partner in order to facilitate both the ILLiad and the Prospector integration presented a challenge. In the case of multiple broker systems (such as INN-Reach and ILLiad) in use at the same institution, Alma requires receipt of the NCIP partner’s code in the ApplicationProfileType element. The INN-Reach NCIP message does not include this element.

In order to accommodate this additional requirement, the Alliance amended the PHP script to include the code of the INN-Reach partner in the ApplicationProfileType element.

Please review the solution below –

$dataPOST = trim(file_get_contents('php://input'));
$dataPOST = str_replace("<INN-REACH SITE CODE>", "<ALMA INSTITUTION ID>", $dataPOST);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//Use your Alma NCIP URL
curl_setopt($ch, CURLOPT_URL, '');
curl_setopt($ch, CURLOPT_POST, true);
//Use INNREACH, or whatever is set up as the partner code for InnReach in your Alma setup
$dataPOST = str_replace("<InitiationHeader>", "<InitiationHeader><ApplicationProfileType><Scheme datatype=\"string\">;scheme=UniqueAgencyId</Scheme><Value datatype=\"string\">INNREACH</Value></ApplicationProfileType>", $dataPOST);
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataPOST);
// Perform RECEIVE
$response = curl_exec($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
// Perform POST
$response = str_replace("<ALMA INSTITUTION ID>", "<INN-REACH SITE CODE>", $response);
$response = str_replace("<Scheme>NCIP Unique Agency Id</Scheme>", "<Scheme>;scheme=UniqueAgencyId</Scheme>", $response);
$response = str_replace("<ALMA INSTITUTION ID>", "<INN-REACH SITE CODE>", $response);
if (strstr($dataPOST, "ItemRequested")){
        $response = str_replace("<Response>", "<ItemRequestedResponse>", $response);
        $response = str_replace("</Response>", "</ItemRequestedResponse>", $response);
// Write Log File
$thismonth = date("Y-m");
$logfile = "ncip" . $thismonth . ".log";
file_put_contents($logfile, "\r\n\r\nREQUEST:" . date("Y-m-d G:i:sa") . "\r\n" . $dataPOST, FILE_APPEND);
file_put_contents($logfile, "\r\n\r\nRESPONSE:" . date("Y-m-d G:i:sa") . "\r\n" . $response, FILE_APPEND);
echo $response;


Leave a Reply