详解php中curl返回false的解决办法
é¦åæ¥çä¸ä¸ªå°è£çcurlå½æ°
function request_post($url = '', $param = '') { if (empty($url) || empty($param)) { return false; } $postUrl = $url; $curlPost = $param; $curl = curl_init();//åå§åcurl curl_setopt($curl, CURLOPT_URL,$postUrl);//æåæå®ç½é¡µ curl_setopt($curl, CURLOPT_HEADER, 0);//设置header curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);//è¦æ±ç»æ为å符串ä¸è¾åºå°å±å¹ä¸ curl_setopt($curl, CURLOPT_POST, 1);//postæ交æ¹å¼ curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);//æ交çåæ° $data = curl_exec($curl);//è¿è¡curl curl_close($curl); return $data; }
è°ç¨çæ¶åè¿åç»æ为bool(false)
æ们å¨curl_exec
å½æ°åé¢éè¿curl_error($curl)
è·åé误ä¹æ¯ string(0) ""
空å符串ã
æååç°èªå·±è°ç¨çapiçæ¥å£å°åæ¯ssl
åè®®çï¼ç¶åå ä¸ä¸é¢ä¸¤ä¸ªå°±å¯ä»¥äº
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
å¦æcurl
请æ±çå°åä¸å«æç©ºæ ¼ä¹ä¼è¿åfalse
çï¼è¿åä¹è¦æ ¼å¤æ³¨æã
ä¹åè¿éå°è¿ä¸ä¸ªè¿åfalse
æå°curl_error($curl)
å¾å°çæ¯å¦ä¸é误
string(39) "Problem (2) in the Chunked-Encoded data" bool(false)
è¿ä¸ªé误ç解å³åæ³è®¾ç½®curl使ç¨çHTTPåè®®çæ¬ï¼å°±æ¯å ä¸ä¸é¢è¿å¥
//CURL_HTTP_VERSION_1_0 (强å¶ä½¿ç¨ HTTP/1.0) //CURL_HTTP_VERSION_1_1 (强å¶ä½¿ç¨ HTTP/1.1)ã curl_setopt($curlp, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
以ä¸æè¿°æ¯å°ç¼ç»å¤§å®¶ä»ç»çphpä¸curlè¿åfalseç解å³åæ³è¯¦è§£æ´åï¼å¸æ对大家ææ帮å©ï¼å¦æ大家æä»»ä½çé®è¯·ç»æçè¨ï¼å°ç¼ä¼åæ¶åå¤å¤§å®¶çãå¨æ¤ä¹é常æ谢大家对èæ¬ä¹å®¶ç½ç«çæ¯æï¼
相关推荐
83911535 2020-11-13
曾是土木人 2020-10-31
yegen00 2020-10-21
soralaro 2020-10-11
katanaFlower 2020-09-18
wytzsjzly 2020-08-17
88407710 2020-08-17
ChinaJoeEE 2020-08-16
CyborgLin 2020-08-15
Blueberry 2020-08-15
PinkBean 2020-08-11
katanaFlower 2020-08-03
hunningtu 2020-07-30
阿债的方寸天地 2020-06-28
pingyan 2020-06-25
wytzsjzly 2020-06-25
阳光岛主 2020-06-25
阿债的方寸天地 2020-06-16