public function post_data($url,$data){
$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_URL, $url); // 要访问的地址
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30 ); //超时断开时间
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); //POST的数据
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //是否接收返回数据
curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: application/json‘,‘Content-Length: ‘ . strlen($data)) );//网页头文件
$result = curl_exec($ch);
echo $result;
}
接收页面
$raw_post_data = file_get_contents(‘php://input‘, ‘r‘);
需要再将数据进行处理;最好在传输页面将数据json_encode这边在json_decode就行了