1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > php 使用curl通过post方式提交json数据

php 使用curl通过post方式提交json数据

时间:2024-03-29 01:49:10

相关推荐

php 使用curl通过post方式提交json数据

独角兽企业重金招聘Python工程师标准>>>

$arrayData = array("name" => "Hagrid", "age" => "36");$sendJsonData = json_encode($arrayData);$ch = curl_init('http://127.0.0.1/jietu/test.php');curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");curl_setopt($ch, CURLOPT_POSTFIELDS, $sendJsonData);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: ' . strlen($sendJsonData)));var_dump(curl_exec($ch));

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。