发布于:2023-03-12 15:59:59
/**
* 发送
* */
public function csss(Request $request){
$url = "url";
$date = '{ "unionId": ""}';
return json($this->http_post($url,$date));
}
function http_post($url, $param)
{
$httph = curl_init($url);
curl_setopt($httph, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($httph, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($httph, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($httph, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
$headers = array(
'Content-Type: application/json;charset=UTF-8',
'Authorization:bearer 加密数据'
);
curl_setopt($httph, CURLOPT_POST, 1);//设置为POST方式
curl_setopt($httph, CURLOPT_POSTFIELDS, $param);
curl_setopt($httph, CURLOPT_CONNECTTIMEOUT, 3);//设置超时时间
curl_setopt($httph, CURLOPT_HTTPHEADER, $headers);
$rst = curl_exec($httph);
//检查是否404(网页找不到)
$httpCode = curl_getinfo($httph, CURLINFO_HTTP_CODE);
// var_dump($httpCode);
$data = json_decode($rst,true);
return [$data,$param,$httpCode];
curl_close($httph);
}
https://blog.csdn.net/qq_34631220/article/details/120233846
阅读 424+
10