menu
more_vert
php 发送post请求 https类型

作者:dayu

/**
* 发送post请求
* @author jiafeimao&dabai
* @createtime 2017-07-26 14:06:04
* @param string $url 请求地址
* @param array $post_data post键值对数据
* @return string
*/

function https_request($url,$data=null){
header("Content-type: text/html; charset=utf-8");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
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_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$tmpInfo = curl_exec($ch);
if (curl_errno($ch)) {
  return curl_error($ch);
}

curl_close($ch);
return $tmpInfo;

}

php 发送post请求 https类型

原文地址:http://www.cnblogs.com/jiafeimao-dabai/p/7241424.html



Processed Time:0.21337795257568

_REQUEST:
Array
(
    [0] => read
    [1] => 94387
)
_SESSION:
Array
(
    [fid] => 4
)