curl-and-php
Re: Slashes and quotes
Date: Tue, 06 Jul 2004 10:52:32 +0200
Hi Antonio,
I am doing the same thing, I'll just provide my code and you can try
whether this will work at your end. I don't fiddle around with the headers,
so maybe there's your showstopper.
I POST XML to an url and get XML back, so I use a function with the XML to
send as a parameter:
function xml_anfrage($fxml) { // post XML to URL and return XML from there
$xmlurl = "http://someserver.com/someurl.asp";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$xmlurl); // URL setzen
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20); // Timeout after 20 secs
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, $fxml); // data to POST, unencoded
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // Put result into variable
instead of displaying in browser
$data = curl_exec($ch); // do it
curl_close($ch);
return $data;
}
This function would be used like this:
$xml = "<?xml
version=\"1.0\"?"."><Request><Mandatnummer>".$fhnr."</Mandatnummer></Request>";
$resultxml = xml_anfrage($xml);
Look at the escaping of the XML header, this might solve your encoding
issue, because I found this was the only variant to make it work. The
results include ISO-8859-15 characters which translate just fine if you
treat them correctly in your PHP code. cURL will work just fine with those.
Best regards,
Thorsten
-- CRT ** Hansemannstrasse 71 ** 41468 Neuss Fon: +49 2131 15 11-119 ** Fax: +49 2131 15 11-150 Web: http://www.crt.de/ ** E-Mail: info@crt.de Ich muß jetzt weg. Wenn ich aufhöre zu rudern, fährt die Galeere im Kreis.Received on 2004-07-06