I have phant installed in my local machine for testing at http://127.0.0.1:8080/
And I have tried to send my data from imp ide to http://127.0.0.1:8080/ but it does not seem to work at all.
I can see that imp is sending data in the log:
2016-06-19 19:52:49 UTC+8 [Agent] Sending particles=0 2016-06-19 19:52:50 UTC+8 [Agent] Phant response: 2016-06-19 19:53:17 UTC+8 [Agent] Sending particles=0 2016-06-19 19:53:17 UTC+8 [Device] Sending Data! 2016-06-19 19:53:17 UTC+8 [Device] particles: 0 2016-06-19 19:53:18 UTC+8 [Agent] Phant response: 2016-06-19 19:53:46 UTC+8 [Device] Sending Data! 2016-06-19 19:53:46 UTC+8 [Device] particles: 0 2016-06-19 19:53:46 UTC+8 [Agent] Sending particles=0 2016-06-19 19:53:47 UTC+8 [Agent] Phant response:
But there is no data receiving on http://127.0.0.1:8080/
Below is my code in imp ide:
///////////////// // Phant Stuff // ///////////////// local publicKey = "xxx"; // Your Phant public key local privateKey = "xxx"; // The Phant private key local phantServer = "127.0.0.1:8080"; // Your Phant server, base URL, no HTTP/////////////////////
// postData Action //
/////////////////////
// When the agent receives a “postData” string from the device, use the
// dataString string to construct a HTTP POST, and send it to the server.
device.on(“postData”, function(dataString) {server.log("Sending " + dataString); // Print a debug message // Construct the base URL: https://data.sparkfun.com/input/PUBLIC_KEY: local phantURL = "http://" + phantServer + "/input/" + publicKey; // Construct the headers: e.g. "Phant-Priave-Key: PRIVATE_KEY" local phantHeaders = {"Phant-Private-Key": privateKey, "connection": "close"}; // Send the POST to phantURL, with phantHeaders, and dataString data. local request = http.post(phantURL, phantHeaders, dataString); // Get the response from the server, and send it out the debug window: local response = request.sendsync(); server.log("Phant response: " + response.body);
});
Any ideas why and what I have missed?