Hi folks,
I'm trying to send an XML request to a server to get its response
back... I can get it to work on the command line (with passthru) but
not with libcurl. I'm using libcurl 7.9.2 which may actually be
different from the curl on the command line... the latter came with
OS X, the former came from entropy.ch with the PHP package I
installed. Of course my host is using 7.9.4 and the script doesn't
work there either.
I've tried it with both GET and POST... here are some setup variables.
$testrequest = "$server?API=Rate&XML=<RateRequest USERID=\"$userid\"
PASSWORD=\"$password\"><Package
ID=\"0\"><Service>EXPRESS</Service><ZipOrigination>20770</ZipOrigination><ZipDestination>20852</ZipDestination><Pounds>10</Pounds><Ounces>0</Ounces><Container>None</Container><Size>REGULAR</Size><Machinable></Machinable></Package></RateRequest>";
$post['API']="Rate\n";
$post['XML']= "'<RateRequest USERID=\"$userid\"
PASSWORD=\"$password\"><Package
ID=\"0\"><Service>EXPRESS</Service><ZipOrigination>20770</ZipOrigination><ZipDestination>20852</ZipDestination><Pounds>10</Pounds><Ounces>0</Ounces><Container>None</Container><Size>REGULAR</Size><Machinable></Machinable></Package></RateRequest>'\n";
# (I've tried it with the 's and without, with the \n's and without)
$d1 = "API=Rate";
$d2 = "XML='<RateRequest USERID=\"$userid\"
PASSWORD=\"$password\"><Package
ID=\"0\"><Service>EXPRESS</Service><ZipOrigination>20770</ZipOrigination><ZipDestination>20852</ZipDestination><Pounds>10</Pounds><Ounces>0</Ounces><Container>None</Container><Size>REGULAR</Size><Machinable></Machinable></Package></RateRequest>'";
$ch = curl_init();
# doesn't work, returns Error 400
curl_setopt($ch, CURLOPT_URL, $testrequest);
# also doesn't work, returns BAD REQUEST
curl_setopt($ch, CURLOPT_URL, $server);
curl_setopt($ch,CURLOPT_POSTFIELDS,$post);
# what DOES work
passthru("curl -d " . $d1 . " -d " . $d2 . " $server");
Any ideas?
-Josh
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php