第三方教程推荐:https://www.cnblogs.com/CHEUNGKAMING/p/5717429.html
?? index.php
<?php ?????header("Content-type: text/html; charset=utf-8"); ????// 请求参数准备 ????$url = "http://www.alayadata.net:8115/api/WX_Register/Sign"; ????$tojson = ‘{"openId":"text","Phone":"18222705995","IdCard":"","MemberName":""}‘; ????$header[] = "Content-Type: application/json; charset=utf-8"; ????$header[] = "Data-signature:C80310638874448266292D70EFA9340C"; ????$header[] = "Time-stamp:1515577396000"; ?????????//初始化 ????$ch = curl_init(); ????// 设置请求地址 ????curl_setopt($ch, CURLOPT_URL, $url); ????// 设置头文件 ????curl_setopt($ch, CURLOPT_HTTPHEADER, $header); ????// 设置获取的信息以文件流的形式返回,而不是直接输出。 ????curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); ????// 设置POST形式传参 ????curl_setopt($ch, CURLOPT_POST, 1); ????// 设置POST请求参数 ????curl_setopt($ch, CURLOPT_POSTFIELDS, $tojson); ????// 开始CURL请求 ????$data = curl_exec($ch); ????// 关闭URL请求 ????curl_close($ch); ????//打印获得的数据 ????echo $data;?>
PHP curl post header
原文地址:https://www.cnblogs.com/CyLee/p/8260039.html