Sorry ingresman - info as follows:
No syntax error - it just stops dead on that line
My bad on sendRequest - had assumed it was a method. Code for the function is as follows:
function sendRequest($path, $body, $xml_only=true, $repeat=true) {
global $amee_host,$amee_port,$responses;
if(!isset($_SESSION["authToken"]) && strpos($path,"POST /auth")===false){
setAuthToken();
}
$authToken=$_SESSION["authToken"];
$header = $path." HTTP/1.0\n"
.getCookieLines() //insert cookies
."Accept: application/xml\n";
if($authToken!=null)
$header.="authToken: ".$authToken."\n";
$header.="Host: ".$amee_host."\n"
."Content-Type: application/x-
."Content-Length: ".strlen($body)."\n"
."\n"
.$body;
//echo($header."<br/>");
$s = socket_create(AF_INET, SOCK_STREAM, 0);
$z = socket_connect($s, gethostbyname($amee_host), $amee_port);
socket_write ($s, $header, strlen($header));
$lines=array();
$lines[0]="";
$i=0;
$xml_line="";
while (true) {
$c = @socket_read($s, 1);
echo($c);
if ($c == "\n" || strlen($c)===0) {
echo($lines[$i]."<br/>\n");
if(strpos($lines[$i],"Set-Cookie:")!==false)
storeCookie($lines[$i]);
else if(strpos($lines[$i],"<?xml")!==false)
$xml_line=$lines[$i];
if(strlen($c)===0)
break;
$i++;
$lines[$i] = "";
}
else
$lines[$i] .= $c;
}
socket_close($s);
if(strpos($lines[0],"401 UNAUTH")!==false){//auth failed, try again, try ONCE at getting new authToken then trying again
if($repeat===true){
debug("<p><b>Authentication failure - get new token and try again.</b></p>");
setAuthToken();
return sendRequest($path, $body, $xml_only, false); //try just one more time!
}
else
debug("Authentication failure on second attempt.");
}
if($_SESSION["debugOn"])
$responses[count($responses)]=array("request"=>$header,"response"=>$lines);
if($xml_only)
return $xml_line;
else
return $lines;
}
//This function creates a new user profile and returns the 12 digit UID.
function createNewProfile(){
$path = "POST /profiles";
$body = "profile=true";
try {
$xmlstr = sendRequest($path, $body);
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
I'm using latest version of php (v5.2.something). Not sure what was on the old laptop as that was setup ages ago - was v5 or later though.