troubleshooting Question

POST problem with php & cURL

Avatar of nsteele84
nsteele84 asked on
2 Comments1 Solution505 ViewsLast Modified:
 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 = "".$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>");

      $error =  print curl_error($ch);
      echo ("Curl Error: $error");

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

Any help would be appreciated.

Thanks Nick Steele
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros