Then i saw someone do it in Perl by sending (Post?) Raw XML to http://www.betfair.com/publicapi/BFService/
This is when i gave it a try in php and voila success! Here is what i did:
$user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL, API_URL ); // set url to post to
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 60); // times out after 1 min
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml ); // add POST fields
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
$header[] = "SOAPAction: ". API_URL;
$header[] = "MIME-Version: 1.0";
$header[] = "Content-type: text/xml; charset=utf-8";
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$result = curl_exec($ch); // run the whole process
if (curl_errno($ch))
{
print curl_error($ch);
return 0;
}
else
{
//now that we have got a result, parse this soap packet and return the XML doc
$parser = new soap_parser($result,'UTF-8','',TRUE);
$result = $parser->get_response();
//print_R($result);
curl_close($ch);
if($result["Result"]["header"]["errorCode"] != "NO_SESSION" )
{
update_session_key($result["Result"]["header"]["sessionToken"] );
}
return $result;
}
To this end i used the PatTemplate system to stuff values into the XML templates, and got the raw XML back. If anyone needs it i can supply the soap parser class i stole ;-). It was one of the class in NuSoap and just changed a few bits here and there.