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?
I was encoding too much of the URL. One should not encode the host, just the parameters.
精彩评论