php模拟post提交
<?php $url = "xxxxx"; // 用户名 $loginName = ''; // 密码 $pwd = ''; // service $serviceName = 'IDNameCheck'; $arr = array ( "loginName" => $loginName, "pwd" => $pwd, "serviceName" => $serviceName, "param" => array ( // 姓名 "name" => 'xxx', // 身份证号 "idCard" => 'xxxxxxxxxxxxxxxxxxx' ) ); $post_data = json_encode($arr, JSON_UNESCAPED_UNICODE); $response = doRequest($url, $post_data); echo urldecode($response); function doRequest($url, $post_data) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $data = curl_exec($ch); curl_close($ch); return $data; } ?>