1

我想通过执行 HTTP (GET) 请求来获取 URL 的 JSON 内容(除非有另一种方法......)。通过 WiFi 执行 HTTP 请求的最佳方式是什么?我正在用 C/C++ 编写这个,所以我想知道一种以编程方式执行 HTTP 请求的方法。

我正在尝试从我拥有的页面中读取一些 JSON。我不确定如何正确执行 HTTP 请求。我正在尝试的代码如下:

  Serial.println(client.print("GET /private/tweets_json.php?count=1&screen_name=rawd_dev HTTP/1.1\r\nHost: example.com\r\nConnection: close\r\n"));

验证“客户端”已在代码中较早地连接。但是,我收到 501 响应:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>501 Method Not Implemented</title>
</head><body>
<h1>Method Not Implemented</h1>
<p>GET to /index.html not supported.<br />
</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>
HTTP/1.0 200 OK
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Vary: Accept-Encoding
Date: Thu, 05 Sep 2013 03:15:12 GMT
Server: Google Frontend
Alternate-Protocol: 80:quic

我不确定是什么原因造成的。应该怎么做?

4

0 回答 0