有以下几种可能:
1、服务器端确实没有数据返回;
2、curl写错了;
3、试试下面这个,我在用的
function curl($url,$post = 'POST',$data = array()){$ch = curl_init()
$headers[] = "Accept-Charset: utf-8"
curl_setopt($ch, CURLOPT_URL, $url)
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $post)
curl_setopt($ch, CURLOPT_POSTFIELDS, $data)
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE)
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE)
curl_setopt($ch, CURLOPT_SSLVERSION, 1)
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers)
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible MSIE 5.01 Windows NT 5.0)')
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1)
curl_setopt($ch, CURLOPT_AUTOREFERER, 1)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true)
$result = curl_exec($ch)
curl_close($ch)
return json_decode($result,1)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)