This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
cdel's profile picture

HTTP Post

Started by cdel, 10 March 2015 - 07:04 AM
cdel #1
Posted 10 March 2015 - 08:04 AM
I am creating a HTTP program that contacts my webserver and saves the posted data to a file. The two post names I am using are "author" and "message" these are the same for both the program and the server. For examples sake, I am just creating a mock up PHP script due to the nature of the script and I have eliminated any other factors that could lead to problems.

post.php:

<?php
  $current = $_POST["author"] . ": " . $_POST["message"];
  echo $current;
?>

program.lua:

local handle = http.post("http://cdel.ddns.net/chirp/post.php", "author=test&amp;message=tset")
print(handle.readAll())

Program.lua should print "test: tset", however it just returns nil. I am using noip.com as I have a dynamic ip address, thought I should mention it, just in case it is effecting the functionality.
oli414 #2
Posted 10 March 2015 - 08:26 AM
I've tested it on my own webserver but it seems to work fine, I'm afraid it is because of your dynamic ip address. You should also check your Computercraft configuration file, HTTP needs to be enabled.
Edited on 10 March 2015 - 07:29 AM
cdel #3
Posted 10 March 2015 - 08:43 AM
HTTP is enabled, it must be the dynamic IP. I'll look into setting up some macros to change my domain records once the router IP change has been detected.

Now that I think about it, it might be due to my internet being slowed (went over my data cap).