PHP Curl Error: Curl__errno () return error code 6

Source: Internet
Author: User
I was using CurlWhen the fetch interface obtains the data, there is Curl_errno ()Return error code ' 6 'The situation, Baidu a bit

CURLE_COULDNT_RESOLVE_HOST (6)Couldn't resolve host. The given remote host was not resolved.

The original program can normally get the interface return data, this situation is suddenly appear, do not know is not the API limit call? At present, we do not know the specific solution, if you encounter the same situation, you can share the solution, thank you.
PS: Directly in the browser to access the interface URL is available to obtain data.
Curl Code:

Public Function Getapidatawithcurl ($params = Array ()) {$doc = array (' result ' =>0, ' content        ' = ', ');        if (!isset ($params [' feed_id ')) return $doc;        if (!isset ($params [' Apikey ')) return $doc;        $GETURL = $this->apiurl. '? ';            foreach ($params as $k = + $v) {if ($v! = ") {$getUrl. = $k. ' = '. $v. ' & ';        }} $GETURL = substr ($getUrl, 0,strlen ($GETURL)-1);        $ch = Curl_init ();        curl_setopt ($ch, Curlopt_url, $GETURL);        curl_setopt ($ch, Curlopt_connecttimeout, 10);        curl_setopt ($ch, Curlopt_timeout, 30);        curl_setopt ($ch, Curlopt_returntransfer, 1);        curl_setopt ($ch, Curlopt_header, false);        $response _content = curl_exec ($ch);        $error _code = Curl_errno ($ch);        $curl _info = Curl_getinfo ($ch);        Curl_close ($ch);        $response _content = simplexml_load_string ($response _content);   $json = Json_encode ($response _content);     $response _content = Json_decode ($json, TRUE); if ($error _code | | (! $response _content && $curl _info[' Http_code ']!=200))        {return ' CURL error:error code '. $error _code;            }else{$doc = Array (' result ' =>1, ' content ' = = $response _content,            );        return $doc; }    }

Reply content:

When I use the Curl interface to obtain data, there is a Curl_errno () return error code ' 6 ' situation, Baidu a bit

CURLE_COULDNT_RESOLVE_HOST (6)Couldn't resolve host. The given remote host was not resolved.

The original program can normally get the interface return data, this situation is suddenly appear, do not know is not the API limit call? At present, we do not know the specific solution, if you encounter the same situation, you can share the solution, thank you.
PS: Directly in the browser to access the interface URL is available to obtain data.
Curl Code:

Public Function Getapidatawithcurl ($params = Array ()) {$doc = array (' result ' =>0, ' content        ' = ', ');        if (!isset ($params [' feed_id ')) return $doc;        if (!isset ($params [' Apikey ')) return $doc;        $GETURL = $this->apiurl. '? ';            foreach ($params as $k = + $v) {if ($v! = ") {$getUrl. = $k. ' = '. $v. ' & ';        }} $GETURL = substr ($getUrl, 0,strlen ($GETURL)-1);        $ch = Curl_init ();        curl_setopt ($ch, Curlopt_url, $GETURL);        curl_setopt ($ch, Curlopt_connecttimeout, 10);        curl_setopt ($ch, Curlopt_timeout, 30);        curl_setopt ($ch, Curlopt_returntransfer, 1);        curl_setopt ($ch, Curlopt_header, false);        $response _content = curl_exec ($ch);        $error _code = Curl_errno ($ch);        $curl _info = Curl_getinfo ($ch);        Curl_close ($ch);        $response _content = simplexml_load_string ($response _content);   $json = Json_encode ($response _content);     $response _content = Json_decode ($json, TRUE); if ($error _code | | (! $response _content && $curl _info[' Http_code ']!=200))        {return ' CURL error:error code '. $error _code;            }else{$doc = Array (' result ' =>1, ' content ' = = $response _content,            );        return $doc; }    }

This is unable to resolve the domain name problem, you try to call out the URL to see if you can ping the

Curl, can you put it on?

Look at you this is the Get method to send value request it! You try file_get_content it directly! Is it a white list for each other?

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.