PHP curl传输json数据及接收


……

//开启header
curl_setopt($curl, CURLOPT_HEADER, true);
//类型为json
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json; charset=utf-8'
)
);

//post传递
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, ($json));
……

……

//接收 $json = file_get_contents("php://input"); $json = json_decode($json, true); print_r($json); ……

 


免责声明!

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



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