$url="api url"; $headers=array('Authorization:11',"X-API-KEY:22"); $ch = curl_init(); $timeout = 5; curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_HTTPGET, true); $file_contents = curl_exec($ch);//获得返回值 dump($file_contents); curl_close($ch); $file_contents 变量返回为 false
1
Jaylee 2016-05-11 15:49:30 +08:00
curl_error()
|
2
william23 OP 奇怪,代码怎么乱了,一楼献上整理过后的代码
$url="api url"; $headers=array('Authorization:11',"X-API-KEY:22"); $ch = curl_init(); $timeout = 5; curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_HTTPGET, true); $file_contents = curl_exec($ch);//获得返回值 dump($file_contents); curl_close($ch); |
3
william23 OP curl_error() 返回值是 60
|