SparkFun Forums 

Where electronics enthusiasts find answers.

Everything pertaining to the data.sparkfun.com service, the phant project which powers it, and user projects which talk to the service.
By Freedom605
#175757
I am using an arduino uno board and I am using an CC3000 board as my wifi module. I tried the GET request using the stream that I made which works perfectly fine. But my problem is that I am having a hard time in using the POST request in the documentation there is only a few information that was given that I should use the link of the total up to the public key only.

This is my public key and private key that I am working on.
http://data.sparkfun.com/input/[publicK ... ial=[value] - I am using this format given to me by the website.

Can anyone help me on this? this code below I am just using trial and error but not able to manage to send it to the stream
Code: Select all
#define WEBSITE      "data.sparkfun.com"
const String publicKey = "o8bbjK6n2rH6N08qvN8N";
const String privateKey = "yz008XJwm9Iv8d9yK898";


      client.print("POST /input/");
      client.print(publicKey);
      client.println("Phant-Private-Key: "); // just a trial 
      client.print(privateKey);
      client.println("HTTP/1.1");
      client.print(F("Host:"));
      client.println(WEBSITE); 
      client.println(F("Content-Type: application/x-www-form-urlencoded"));
      client.println("Connection: close");
      client.print(F("Content-Length: "));
      client.print(request.length());
      client.println();
      //Phant-Private-Key: PRIVATE_KEY
      //client.print("?private_key=");
      client.print("trial=");
      client.println(request);      
      client.println();
      Serial.println("Connected & Data sent");
By Freedom605
#175767
Yes I am aware, that is what I am using it but it uses GET request not POST request. Using GET request is not secure which it adds the information into the URL which I am asking the what is the correct way in using the POST request which stated in the documentation that it can also can be made through the use of POST but without an example.
By Kamiquasi
#175769
Freedom605 wrote:Yes I am aware, that is what I am using it but it uses GET request not POST request. Using GET request is not secure which it adds the information into the URL
Note that POST is also not secure, as its data can be read just as well by anybody intercepting the packets.
However, as data.sparkfun.com runs happily over a secure connection (https), either GET or POST will be secure in terms of the data transfer - the exact URL is already encrypted.

Though I do think that if you're working with data that you want to keep secret, sending that data 'as is' to a third party hosting service may not be advisable in the first place :)
By Freedom605
#175771
Can you teach me on how I can do POST request using the site? I am not sure what should be the proper code must be. At least I can able to send the data thru GET and POST(if I know how) :D
By Valen
#175773
I don't have a network shield for my Arduino so I have no direct experience with Phant or Arduino networking. Not even from a PC level programming. I just looked through this tutorial out of curiosity. So, I'm not much help.

I do remember reading in the sparkfun tutorial or phant documentation that you can also run it on your own pc or server. So if you really need it to be secure in terms of secrecy then hosting it on a private server in your lan would be best.