企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
~~~ 发送json数据 ~~~ 要用PHP cURL模拟发送的话,需要发送相应的header参数,示例: ~~~ <?php #json数据 $url = 'http://test.com/curl/testPostJsonData.php'; $data = '{"a":"b"}'; $length = strlen($data); $header = array( 'Content-Length: ' . $length, //不是必需 'Content-Type: text/json', ); $ch = curl_init($url); //初始化curl curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $content = curl_exec($ch); //执行并存储结果 curl_close($ch); echo $content; ?> ~~~