GET请求的格式


Format of GET Request

我有一个运行MySQL的外部服务器。我安装了一个PHP脚本,当从HTTP访问时,它将从其中一个表传递数据。

它在浏览器中运行良好:

http://www.seti.net/php/getEvents.php

但我不知道如何从Arduino发出这个命令。我有EthernetClient库在工作,可以访问Google,如示例所示。当我通过客户端发送此命令时:

client.println("//GET /php/getEvents.php HTTP/1.0");

服务器返回:

</head><body>
<h1>Method Not Implemented</h1>
<p>GET to /php/getEvents.php not supported.<br />

在Arduino中格式化GET的正确方法是什么?

试试这个。

client.println("GET /php/getEvents.php HTTP/1.0");

更新

  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.println("connected");
    // Make a HTTP request:
    client.println("GET /php/getEvents.php HTTP/1.0");
    client.println("Host: www.seti.net");
    client.println("Connection: close");
    client.println();
  } 
  else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }