I am currently trying to send three coordinates through the output port of the imp to an HTTP Request node which will send the data via POST to a php script. The problem I am encountering is when I try to read the data on the php side, I can only read one of the coordinates.
Is it possible to send an array through POST using the imp? I am fairly new at squirrel and php/html so please forgive me if I sound like I don’t know what I am talking about.
I define my array as:
local array = [someX, someY, someZ];
and set my output:
output.set(array);
and I configure:
imp.configure("Coordinate Buffer", [], [output]);
On the PHP side I try to access the ‘someX’ variable with:
$_POST['value'][0]
as well as the other two indices for the Y and Z variables but this doesn’t seem to work. Any input would be greatly appreciated!
You may try passing the output type (in this case, its type is an “array”) into the constructor of the OutputPort when you create the output object, as such: (the names in this particular case may lead to confusion since they are quite similar) output <- OutputPort("value", "array");
Which definitely sets the output port to send an array (thank you!), and I know it is sending the correct values, but now I think the problem is in the PHP side.
When I connect the noodle from the imp to the HTTP Request, it says (under destination outputs: value[string]. Could this be the problem, can I change what type of variable the HTTP Request node receives?
I also tried the method posted above which was also helpful:
It would only show the Xcoord, in this case $item[0]. When I printed them to a file, again only the $item[0] variable would print and $item[1] and $item[2] would both print blank characters.
Make this simple HTML page and perhaps called it “testing.html” …
`
Item 1:
Item 2:
Item 3:
`
Now, create a PHP script called “test.php” …
`
<?php
$items=$*POST['value'];
echo "This is the array of values: ";
print_r($items);
echo "
These are the items individually: ";
echo $items[0]." ";
echo $items[1]." ";
echo $items[2]." ";
?>
`
If the PHP script works (displaying the array of values), then you know the PHP part is correct. Now you can work on the imp side of it.
NOTICE
And I am just noticing that the underscore does not appear on this editor.
That’s too bad because the underscore is important. I’ll put an asterisk where there is supposed to be an underscore.