php curl couldn’t connect to host

Posted on Posted in 时事八卦, 最新资讯
        $url = 'http://xxx.net';
        $curl = curl_init();
        curl_setopt_array($curl, array(
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => TRUE,
            CURLOPT_TIMEOUT => 30,
            CURLOPT_CUSTOMREQUEST => "GET",
        ));

        $response = curl_exec($curl);
        $err = curl_error($curl);

        curl_close($curl);

        if ($err) {
            return "cURL Error #:" . $err;
        }
        return $response;

xxx.net 是本地绑定的Host
浏览器访问是正常的
php curl 就couldn't connect to host

回复内容:

        $url = 'http://xxx.net';
        $curl = curl_init();
        curl_setopt_array($curl, array(
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => TRUE,
            CURLOPT_TIMEOUT => 30,
            CURLOPT_CUSTOMREQUEST => "GET",
        ));

        $response = curl_exec($curl);
        $err = curl_error($curl);

        curl_close($curl);

        if ($err) {
            return "cURL Error #:" . $err;
        }
        return $response;

xxx.net 是本地绑定的Host
浏览器访问是正常的
php curl 就couldn't connect to host

你用的什么环境啊?

该文章由WP-AutoPost插件自动采集发布

原文地址:http://www.php.cn/php-weizijiaocheng-96763.html

发表评论

电子邮件地址不会被公开。 必填项已用*标注