Http request

Hi, I am trying to use the http request node to send data to my server on the godady website. I don’t know how to read the data on the other end. Here is what i have tried. So far i haven’t been able to see any data on my server.

On the http request node, I sent the data to “http://mydomain/index.php

On the server, I made a file “index.php” with the following code

<?php echo file_get_contents('php://input'); ?>

Use POST method in your request node.

Use this to test on the PHP side of it …

<?php if($_POST['value']){ $v = $_POST['value']; echo "The value coming in is: ".$v; } ?>

There are underscores here: $_POST (they don’t show up when used with code highlight). This forum text editor really sucks big time.

After the imp sends something, you’ll have to refresh your index.php page to see the value.

You can use javascripting to refresh your page every 10 seconds if you want.

Post your imp code here if you still have problems. Or use the planner to make sure you’re really sending out a value.

It still doesn’t work. Currently I am only sending 1’s and 0’s. I can see the 1 and 0 on the planner. Here is my imp code:

`local inputData= 0;
local output = OutputPort(“value”, “number”);
hardware.pin9.configure(DIGITAL_IN);

function getData()
{
inputData= hardware.pin9;
local value= inputData.read();
output.set(value);
server.show(value);
imp.wakeup(0.5, getData); //500ms
}

imp.configure(“SensorData”, [], [output]);
getData();`

Thanks

List your PHP script and describe what settings you have in your http request node, or upload a screenshot of your planner. You are seeing things on your server log so that part is OK. It has to be either the http request node or the PHP script.

Also, maybe the 0.5 is too fast and something happens because of that?
Try making it 5 seconds just for testing.

So far, everything you’re doing is looking OK to me.

I attached a screen shot of the planner. the x is where i put my domain name. I changed the time to 5 sec and still no luck
here is the php code I am using
`

testing <?php if($_POST['value']){ $v = $_POST['vaue']; echo "The value coming in is: ".$v; } ?> `

Don’t use json … use the x-www-form-urlencoded

click down-arrow and select the other one.

Also see my post about WiFi in “got imps”? Examples of PHP sending back values without using HTML forms. You might be interested in that part too.

It works now, just needed to save the data on a file first. Thanks for your help!