SIP Strings For Patron Accounts

Previously, we’ve looked at how to make our web server talk to our SIP server, and how to make PHP talk to our SIP server. Let’s start to retrieve some real data from SIP.

Sending some garbage text to SIP, and receiving a 96 code is great, but now let’s define some real codes. To do this, log into your SIP server. Navigate to where you have installed SIP. You should see a folder called ‘sirsidynix’. This folder will contain folders for each of the SIP connections you have a license for (so as an example, we have 8). Each one should be named in a fairly straightforward way. Go into the one that you will be using.

Now that you’re into the right folder for your connection, navigate into the bin folder. Here you should see a file called AcsTester.exe. Run that program and you should see something like this screen shot.

At the top of the program window, you’ll see a button labeled “Create Message”. Clicking that will give you a list of different messages that you can send to SIP. For this excercise, let’s use Patron Status Request (but also take note of the “Fee Paid” message – you should be connecting dots at this point).

As far as I know, what you will see at this point will vary slightly from connection to connection, based on the settings and setup for that connection. For example, requiring the patron’s pin may be turned off, requiring a transaction date may be turned off, and likely any other number of settings can affect this. I’m going to show a screen shot of what I entered, so that you can follow along when I generate my actual SIP message.

The end result is this message string:

2300120110501    102705|AO|AAmyBarcodeHere|AC|AD1234|AY0AZF001

Let’s feed this string into the code we created in the last article, and we should receive back a real patron’s status.

Basic Code

<?php
	$sip_server_address = 'MyServerName';
	$sip_server_port = 2023;

	$fp = fsockopen($sip_server_address,$sip_server_port,$errno,$errstr);
	stream_set_blocking($fp, 0);
	
	$check = '2300120110501    102705|AO|AAmyBarcodeHere|AC|AD1234|AY0AZF001';

	fputs($fp, "$check\r");
	sleep(2);

	$response = fread($fp, 256);

	echo $response;
?>

This should return a code for the user. Again, this code will look a little different from system to system, but should be fairly recognizable regardless. If the user has no fines, it will typically have this code in it “BLY|CQY”. We’ll set up our message to be a bit more dynamic below, so you can try a few barcodes, with a few results to see how a patron with a block appears, a patron that owes fines, a patron that is in good standing, etc.

Break It Down Further

So we should know have the basic code working. Let’s separate out that $check variable and make it a bit more dynamic so that it’s built off of the current date, and with whatever barcode you want. Then we can start to trap our output and return some real messages.

	$sip_server_address = 'MyServerName';
	$sip_server_port = 2023;
	$barcode = '999999999';
	$pin = '1234';

	$fp = fsockopen($sip_server_address,$sip_server_port,$errno,$errstr);
	stream_set_blocking($fp, 0);
	
	$check = '23001' . date('dmY') . '    102705|AO|AA' . $barcode . '|AC|AD' . $pin . '|AY0AZF001';

	fputs($fp, "$check\r");
	sleep(2);

	$response = fread($fp, 256);

	switch($response) {
		case (strpos($response,'BLY|CQY|AY')!==FALSE):
			echo '<p>You do not owe any fines!</p>';
			break;
		case (strpos($response,'BLY|CQY|BH')!==FALSE):
			echo '<p>You owe fines!</p>';
			break;
		case (strpos($response,'Incorrect password')!==FALSE):
			echo '<p>Your pin does not match!</p>';
			break;
		case (strpos($response,'Unknown borrower barcode')!==FALSE):
			echo '<p>Your barcode was not found!</p>';
			break;
		default:
			echo '<p>We need to make a definition for this message: ' . $response . '</p>';
			break;
	}

Note For Other ILS’s

I want to be very clear that your mileage may vary with this code. This is what works for me, with a Horizon setup. I had a friend look into III’s setup, and he came back from the manuals that a lot of their SIP stuff is integrated with the WebPAC and Express Lane products only. They do offer the Fine Payment Web Service for this type of integration, but that comes at a price (cost is unknown, he didn’t go to his sales rep yet).

Sum Up

I hope this crash course in SIP programming has been beneficial to you. As always, please leave a comment to let me know how this is (or isn’t) working out for you.

4 Responses to “SIP Strings For Patron Accounts”

  1. Mike Says:

    On III, we don’t seem to have a message string generation tool. When I plug in the string you posted exactly as is, I get:

    24Y 001201105060000112132AOcambp|AAmyBarcodeHere|AENo Name|BLN|AFYour library card number cannot be located. Please see a staff member for assistance.|AY0AZCA4E

    When I replace the barcode field with my barcode, I get:

    96AY0AZFE2C

    I also made sure to change the date in the static connection string but it is still 96. Now we don’t use PINs so I’m not sure how to handle that. I’ve tried setting it to blank, removing the field altogether, no dice. Any ideas?


  2. cdunne Says:

    To state the obvious, did you swap in a barcode?


  3. Mike Says:

    ^

    “When I replace the barcode field with my barcode, I get:

    96AY0AZFE2C ”

    😛


  4. Chris Says:

    I followed your tutorial and everything worked, thanks! Now I’m just looking for the next step. Any advice? Did you just do trial and error or did you have some documentation to work off of? Thanks again for your help.


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>