cURL:无法解析主机:xx.com [ping xx.com ok和xx.com是我的本地域名]

时间:2015-08-26 02:30:44

标签: php curl dns

function curl_upload($post_url, $post_data) {
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $post_url);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0");
    $result = curl_exec($curl);
    $error = curl_error($curl);
    curl_close($curl);
    return $error ? $error : $result;
}

$data = curl_upload('http://xx.com/lists', $condition);
echo $data;exit();

然后运行php代码,告诉我:

有时会显示Could not resolve host: xx.com

有时会显示正确的数据

我试着解决它,我谷歌它,但不工作。所以我在这里寻求帮助。

ping xx.com好的

我的resolv.conf:

nameserver 8.8.8.8 nameserver 114.114.114.114

myhosts:

/ etc / hosts中: xx.com 127.0.0.1

谁能给我帮助,Tks !!

0 个答案:

没有答案