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?