I haven't done this before, so I'm not sure what I'm doing wrong.
The XML looks correct, yet by echoing the response from the site I get
HTTP/1.1 400 Bad Request
Content-Type: text/html
Date: Fri, 19 Mar 2010 16:16:06 GMT
Connection: close
Content-Length: 20
<h1>Bad Request</h1>
Here's some sample of the code I'm using to connect in PHP.
Code: Select all
$fp = fsockopen("example.com", 80, $errno, $errstr, 30);
if (!$fp)
{
echo 'Could not open connection.';
}
else
{
$xmlpacket ='<?xml version="1.0"?>'; ///*Begins building packet
Code: Select all
$out = "post /PartnerInterfaceServlet http/1.0\r\n"; /// script name
$out .= "Host: example.com/servlet\r\n"; /// Host name
$out .= "Connection: Keep-Alive\r\n";
$out .= "Content-type: application/x-www-form-urlencoded\r\n";
$out .= "Content-length: ".$contentlength."\r\n\r\n";
$out .= "xml=".$xmlpacket."";
fwrite($fp, $out);
while (!feof($fp))
{
$theOutput .= fgets($fp, 4096);
}
fclose($fp);