新手求助:如何向指定端口的CameraTools发送JSON命令?
Windows下CameraTools接口的CURL命令写法(含JSON数组场景)
Windows的CMD和PowerShell环境对引号转义的规则不同,以下分别给出两种环境下的正确单行命令:
CMD环境
在CMD中,双引号需要用两个连续双引号来转义,确保JSON结构被完整解析:
- 获取所有相机列表:
curl -X POST -H "Content-Type: application/json" -d "{""command"":""getAllCameras""}" http://192.168.0.108:809
- 发送录制命令给指定相机:
curl -X POST -H "Content-Type: application/json" -d "{""command"":""sendCameraCommand"",""cameras"":[""GoPro 2281""],""cameraCommand"":""startRecording""}" http://192.168.0.108:809
PowerShell环境
PowerShell支持用单引号包裹JSON字符串,内部双引号无需转义,写法更简洁:
- 获取所有相机列表:
curl -X POST -H "Content-Type: application/json" -d '{"command":"getAllCameras"}' http://192.168.0.108:809
- 发送录制命令给指定相机:
curl -X POST -H "Content-Type: application/json" -d '{"command":"sendCameraCommand","cameras":["GoPro 2281"],"cameraCommand":"startRecording"}' http://192.168.0.108:809
注意
- 确保系统已预装curl(Windows 10 1803及以上版本默认包含),如果没有需单独安装。
-H "Content-Type: application/json"参数必须添加,告知接口接收的是JSON格式数据。
内容的提问来源于stack exchange,提问作者Gerald_D
相关产品推荐
相关产品推荐

