0

Im trying to send data with CURL to an address like this.

$ch = curl_init("url address im sending data to.");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt ($ch, CURLOPT_HTTPHEADER, array('"Content-type: text/plain; charset=UTF-8"'));
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_object);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($curl, CURLOPT_POSTREDIR, 3);
curl_exec($ch);

However, my curl_errno($ch) returns 6 which is a "Couldn't resolve host." error.

Any idea why I'm getting this error and a solution to fix?

Thanks in advance!

  • Did you see this: https://stackoverflow.com/q/1341644/231316 – Chris Haas Aug 20 '20 at 18:55
  • @ChrisHaas yes I removed the http:/ from my url and tried the solution by including CURLOPT_DNS_USE_GLOBAL_CACHE, CURLOPT_DNS_CACHE_TIMEOUT, CURLOPT_IPRESOLVE and still the same error. my url is in this format => $url = "www.xxxxxxxxx"; – suhyung lee Aug 20 '20 at 20:36

0 Answers0