Link to home
Start Free TrialLog in
Avatar of nsteele84
nsteele84

asked on

POST problem with php & cURL

HI
 I am trying to post to a URL and receive a reply from it. I am trying to use cURL but it is new to me and I am having some problems Here is what I have so far:

$url = "http://production.shippingapis.com/ShippingAPI.dll?API=RateV4&XML=".$post_string;

$header = "POST HTTP/1.0 \r\n";
$header .= "Content-type: text/xml \r\n";
$header .= "Content-transfer-encoding: text \r\n";

$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER ,0);
curl_setopt($ch, CURLOPT_URL ,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
curl_setopt($ch, CURLOPT_TIMEOUT ,4);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST ,$header);

$data = curl_exec($ch);

echo("Return Data: $data  <P>");

if(curl_errno($ch)){
      $error =  print curl_error($ch);
      echo ("Curl Error: $error");
}else{
      curl_close($ch);
}


$post_string is a block of xml. This returns an error code of 1.

Any help would be appreciated.

Thanks Nick Steele
ASKER CERTIFIED SOLUTION
Avatar of Rik-Legger
Rik-Legger
Flag of undefined image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nsteele84
nsteele84

ASKER

Great Thanks