←  Ask a Pro

ComputerCraft | Programmable Computers for Minecraft

»

HTTP Post

cdel's Photo cdel 10 Mar 2015

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&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.
Quote

oli414's Photo oli414 10 Mar 2015

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 by oli414, 10 March 2015 - 08:29 AM.
Quote

cdel's Photo cdel 10 Mar 2015

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).
Quote