$options = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type:application/x-www-form-urlencoded',
'content' => $postdata,
'timeout' => 15 * 60 // 超时时间(单位:s)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); //设置访问的url地址
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //设置超时
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1); //跟踪301
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //返回结果
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, 1);//设置为POST方式
//$data = urldecode ( json_encode ( $param ) );
curl_setopt($ch, CURLOPT_POSTFIELDS, $param); //设置参数
//curl_setopt ($ch, CURLOPT_HTTPHEADER, $headerInfo);
$r = curl_exec($ch);
curl_close($ch);
return $r;