我正在尝试将一些json格式的数据发送到我的服务器,该服务器只接受http POST请求。我试过下面的代码。
AT
AT+CREG?
AT+CGATT?
AT+CIPSHUT
AT+CIPSTATUS
AT+CIPMUX=0
AT+CGDCONT=1,"IP","mtnirancell"
AT+CSTT="mtnirancell","",""
AT+CIICR
AT+CIFSR
AT+CIPSTATUS
AT+CIPSTART= "TCP","(host)","8080"
AT+CIPSEND
>
POST http://(host):8080/api/v1/$ACCESS_TOKEN/telemetry HTTP/1.1 (Ctrl+M + Ctrl+J)
HOST: (host) (Ctrl+M + Ctrl+J)
Accept: application/json (Ctrl+M + Ctrl+J)
Content-Type: application/json (Ctrl+M + Ctrl+J)
{(json data)} (Ctrl+M + Ctrl+J)
(ctrl+j)(ctrl+z)
问题是它在最后4行中一直说SIM 808 R14.18 ERROR。它还会关闭连接并显示CLOSED。
事实上,我使用了这个非常好用的PHP代码。我只想在SIM 808模块中使用相同的代码。
<!DOCTYPE html>
<html>
<head>
<title>Record</title>
</head>
<body>
<?php
$url = "http://(host):8080/api/v1/$ACCESS_TOKEN/telemetry";
$ch = curl_init($url);
$data = file_get_contents("data.json");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($ch);
echo $result;
?>
</body>
</html>