使用ESP8266到localhost

时间:2016-10-01 03:10:38

标签: php http post esp8266 arduino-esp8266

我试图从ESP8266发出POST请求,并通过URL发送两个变量值。我有的POST请求如下所示。

client.print(String("POST ") + url + 
     " HTTP/1.1\r\n" + "Host: " +
      host + "\r\n" + "User-Agent: Arduino/1.0\r\n" + "Cache-Control: no-cache\r\n" + 
      "Content-Type: application/x-www-form-urlencoded" + "\r\n" + "Connection: close\r\n\r\n" +
      "Content-Length: " +  post.length() + "\r\n" +  post );

POST数据是这样的。

String post = "number=1&status=OFF";

我使用XAMPP来托管网页。一切似乎都运行良好,但执行后我收到的是PHP页面上的。

  

注意:未定义的索引:C:\ xampp \ htdocs \ pumpupdate.php中的数字   第3行

     

注意:未定义索引:C:\ xampp \ htdocs \ pumpupdate.php中的状态   第4行

这意味着PHP脚本中的$_GET参数不会从发送到页面URL的变量中检索到。当我尝试手动更新URL时,它工作正常,我得出结论,PHP文件正常工作。

请告知。

0 个答案:

没有答案