2013-11-15 260 views
1

我有一堆温度数据是我想要放入Google Fusion表格中的Arduino监视器。 Fusion表格需要使用OAuth作为Arduino无法处理的记录插入(我不认为),我想创建一个小应用程序Google的App Engine,它将接收来自Arduino的数据,然后这个应用程序将使用Fusion表进行身份验证并插入一条记录。每个记录将有大约65个字段。我不知道如何在Google App Engine上执行该应用,但我会分开计算。我想知道的是使用来自我的Arduino的GET请求或POST请求将数据发送到应用程序的优点和缺点。对于这种情况,是另一种更好的选择吗?Arduino POST vs GET请求

回答

0

如果您想从Arduino发送数据,您将需要使用HTTP POST请求。

两者之间的区别是,GET是用于请求数据从服务器,而POST是将数据发送到服务器。

这里是关于HTTP消息类型的链接信息:用于Arduino的代码 http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4

现在,你需要做以下发送使用GSM Shield POST请求。

//First, establish a connection to the cell tower via GSM 
String PIN = "123456"; //The PIN of your SIM card 
gsmAccess.begin(PIN); 

//Next, connect to your service provider's GPRS network (internet access) 
String GPRS_APN = "The APN of your provider"; 
String GPRS_LOGIN = "Your login name"; 
String GPRS_PASSWORD = "Your password"; 
gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD); 

//Now you need to connect a client to your GAE web server on port 80 
client.connect("ServerName", 80); 

//Now send the properly-formed HTTP POST request 
String message = "The message body of the request, the data you want to send"; 
client.print("POST "); 
client.print("/yourPathToDesiredPage"); 
client.println(" HTTP/1.1"); 
client.print("Host: "); 
client.println("ServerName"); 
client.println("Content-Type: text/plain"); 
client.print("Content-Length: "); 
client.println(message.length()); 
client.println(); 
client.println(message); 
client.endWrite(); 
+0

如果我的回答对你有帮助,你能接受/ upvote吗?如果不是,你能否详细说明我还能如何帮助? – Adrogans