Hi Jochem,
Thanks very much for your help. I now have the application working. Just for
anyone elses interest here are a few comments.
>> $length = "Content-Length: 502";
JM> The way I see it your Content-Length is wrong - the
JM> length of your request in this instance would 380 bytes,
JM> based on the length of $xmlstr. but that's probably not right
JM> either.
JM> I imagine you need to set Content-Length dynamically,
JM> assuming curl doesn't do that for you ...
Yes curl does it for you I have discovered. So I removed this Content-Length and
found that it is now dynamically generated.
JM> as a side note: why bother setting all these vars then stricking
JM> them in an array - why not just stick the strings directly in the array?
JM> additionally if you don't need to use double quotes (for variable
JM> interpolation) single quotes are [marginally] faster [in theory] because
JM> no variable interpolation is attempted on them.
Because I was being a bit lazy and wanted to see more of what was going on. Of
course you are right and I have now cleaned up my code as you have suggested.
>> $a_encoding = "Accept-Encoding: gzip";
JM> not related to your current issue, but are your really accepting
JM> a gzip'ed reply? this might cause you headaches once you have the
JM> current problem solved.
Yeah this gzip is a real pain. The API specifies either a gzipped or a
compressed data transfer. Some of the returns from the server, in Germany, can
be quite large so I guess the developers wanted to save some bandwidth by
compressing the data. I have just discovered that if I leave the
Accept-Encoding: gzip out all together then the whole process works with the
data returned in plain uncompressed text :-)
>> curl_setopt($curl, CURLOPT_POSTFIELDS, urlencode($xmlstr));
JM> I am guessing that the urlencoded $xmlstr should be given a POST parameter
name,
JM> what that name is I don't know but the previous line should look something
like
JM> this (*I think*):
JM> curl_setopt($curl, CURLOPT_POSTFIELDS, array('xml' => urlencode($xmlstr)));
This was where I had suspected I was having trouble. What I did find was that
the whole thing now works just by removing the urlencode all together. It
appears that the Content-Length was the problem all along and once that was
fixed and the urlencode was removed everything was fine.
JM> you might consider point the curl request to a script you control,
JM> so that you can see exactly what the request is sending.
JM> e.g. $url = 'http://yourdomain.tld/your-curl-request-test.php';
JM> ... and have your-curl-request-test.php write all it's recieved headers, etc
JM> to a log file.
Probably a good idea for debugging.
Thanks for your help.
Regards,
Richard Luckhurst
Product Development
Exodus Systems - Sydney, Australia.
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php