donk
donk

Reputation: 1570

curl could not resolve host URL cut off

I'm getting a cURL error "Could not resolve host" and then it shows a cut off URL. The generated URL is fine, because when I enter it to the browser, it works.

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
if (!$result = curl_exec($ch))
{
    die ('Curl Error: '.curl_error($ch));
}
curl_close($ch);

Why does it do that?

Upvotes: 0

Views: 1473

Answers (1)

donk
donk

Reputation: 1570

I was encoding too much of the URL. One should not encode the host, just the parameters.

Upvotes: 1

Related Questions