<?php
	include("AuthentComms.php");
	
	$msg = new Message();
	
	#$msg->tsoid = "Auth_Sandbox";
	$msg->tsoid = "Authentrus";
	$msg->application = "PhoneConfirm";
	$msg->asid = "Customer_Identifier";
	#$msg->action = "PhoneSession";
	#$msg->type = "request";
	#$msg->data["phoneNumber"] = new DataNode("7735551212");
	$msg->data["licensekey"] = new DataNode("dc391483-473c-4c3a-80d8-61ce0d0f60a9");
	$msg->data["phoneNumber"] = new DataNode("6174130706");
	#$msg->data["pinNumber"] = new DataNode("1234");
	$msg->data["confirmNumber"] = new DataNode("1234");
	$msg->action="PhoneSession";
	
	$comms = new AuthentComms("https://imp.authentify.com/s2s/default.asp");
	echo "<br/>This is the XML of the newly minted AuthentComms, comms<br/>";
	echo htmlize($msg->toXML());
	echo "<br>";
	echo "This is the object<pre>".print_r($comms,true)."</pre>";
	flush();
	
	$newmsg = $comms->sendMessage($msg);
	echo "<br/>This is the XML (or an error statement) of the newly minted newmsg derived from send the comm message.<br/>";
	if( !isset($newmsg) ){
		echo $comms->lastError;
	}else{
		echo htmlize($newmsg->toXML());
	}
	echo "This is the object<pre>".printf_r($newmsg,true)."</pre>";
	flush();
	
	while(isset($newmsg) && $newmsg->type != "result"){
		sleep(10);
		$newmsg = $comms->sendPoll();
		if( !isset($newmsg) ){
			echo $comms->lastError;
			break;
		}
		echo htmlize($newmsg->toXML());
		echo "<br>";
		flush();
	}
	
	
	function htmlize($str){
		$out = str_replace("<", "&lt;", $str);
		$out = str_replace(">", "&gt;", $out);
		$out = str_replace("\t", "   ", $out);
		$out = str_replace(" ", "&nbsp;", $out);
		$out = str_replace("\n", "<br>\n", $out);
		return $out;
	}
/* 
 This is the XML of the newly minted AuthentComms, comms
 < ?xml version="1.0" encoding="ISO-8859-1"? >
<AuthentXML xmlns = "http://xml.authentify.net/MessageSchema.xml" version = "1.0">
<header>
<tsoid>Auth_Sandbox</tsoid>
<application>PhoneConfirm</application>
<asid>Customer_Identifier</asid>
</header>
<body>
<>
<data xmlns:dat='http://xml.authentify.net/CommonDataSchema.xml'>
<dat:licensekey>dc391483-473c-4c3a-80d8-61ce0d0f60a9</dat:licensekey>
<dat:phoneNumber>6174130706</dat:phoneNumber>
<dat:confirmNumber>1234</dat:confirmNumber>
</data>
</>
</body>
</AuthentXML>

This is the XML (or an error statement) of the newly minted newmsg derived from send the comm message.
< ?xml version="1.0" encoding="ISO-8859-1"? >
<AuthentXML xmlns = "http://xml.authentify.net/MessageSchema.xml" version = "1.0">
<header>
<replyTo>https://imp.authentify.com/s2s/default.asp</replyTo>
</header>
<body>
<result>
<status>
<statusCode>2510</statusCode>
</status>
</result>
</body>
</AuthentXML>


<AuthentXML xmlns="http://xml.authentify.net/MessageSchema.xml" version="1.0">
<header>
55 <tsoid>Auth_Sandbox</tsoid>
55<asid>Customer_Identifier</asid>
??? <sgid>a3858c7b-8862-451c-ae64-7fe60b6808c5</sgid>
<application>PhoneConfirm</application>
<account>AuthenticityInstitute</account>
<teid>55bbdf03-58ed-47f0-bc3f-bc6f23477559</teid>
<replyTo>https://imp.authentify.com/s2s/default.asp</replyTo>
<timestamp>2013-01-09T16:33:54Z</timestamp>
</header>
<body>
<report>
<action>ParmsOK</action>
<status>
<statusCode>7000</statusCode>
</status>
</report>
</body>
</AuthentXML>

*/
?>