Php 通过curl提交post内容为 Json的请求


<?php
$data = array("cNos" => array("1064917432615","1064917432615"), "date" => "20170515"); 

$data_string = json_encode($data);
print_r($data_string);
$ch = curl_init('http://****/BatchQuery/Post1?eId=30005');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string))
);
curl_setopt($ch, CURLOPT_ENCODING, 'deflate');

$result = curl_exec($ch);
print_r($result)
?>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM