Using curl to report couldntconnecttohost error PHPcode sends post request function_xpost ($ url, $ p) {$ f; $ data; foreach ($ pas $ k & gt; $ v) {$ data. $ f. $ k .. when urlencode ($ v) uses curl to report a couldn't connect to host error
PHP code
// Send the post request function _ xpost ($ url, $ p) {$ f = ''; $ data =''; foreach ($ p as $ k => $ v) {$ data. = $ f. $ k. '= '. urlencode ($ v); // $ data. = $ f. $ k. '= '. $ v; $ f = '&';} // echo $ data.'
'; $ Curl = curl_init ($ url); curl_setopt ($ curl, expires, 1); curl_setopt ($ curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt ($ curl, expires, 1); curl_setopt ($ curl, CURLOPT_POST, 1); curl_setopt ($ curl, CURLOPT_POSTFIELDS, $ data); $ res = curl_exec ($ curl ); if (curl_errno ($ curl) {echo 'curl error :'. curl_error ($ curl);} curl_close ($ curl); return $ res ;}
I call this function and send a text message, which can run normally on the local server. However, the Curl error: couldn't connect to host error is reported when deployed on the network server, what's going on? Solution
------ Solution --------------------
You can ping the host URL on the server to see if it works?
It may be because the DNS server settings of the server are incorrect, and the host cannot be found. In addition, if the ip address of your server is blocked by the other party, this prompt will appear.
------ Solution --------------------
Agree upstairs
------ Solution --------------------
Can you connect with foskopen?