Author Topic: Any way to send data via the POST method?  (Read 1889 times)

I've recently had a sudden revelation of ideas if it's possible to use the POST method with Torque. Is there anyway to do it?

Also, I should be able to send a password(So people can't figure out and then spam whatever I might use it for), do I have to worry about a password being sent like that?


Obviously I would need an IP or a file to find on the internet.
« Last Edit: January 19, 2009, 10:55:27 AM by Kalphiter »

You just want to send data via POST?

The answer really depends on why you're sending data.. and what type of data.

I was just wondering this too.  It would be nice if someone would explain how to connect with a server, send data with post ( various kinds ) and then also reading the page.  I talked with Trader on this subject, and he said he learned from the Garage Games website, and told me to search there, but most of the search results are in forums hidden to me, or don't have a decent description on how to use it.


Also for my use I want to send data to a php document.

I'm just sending CityRP data, and that's really it.

I understand how to use PHP, but it's the Torque side I really need help with.

Well RTB's pretty much based on using the POST method so i'd look at that - I won't be providing any of the server-side code though.

Edit: To avoid having to learn how to form correct HTTP requests and all the headers it needs i'd suggest just passing your variables in the url as GET parameters.
« Last Edit: January 19, 2009, 12:20:01 PM by Ephialtes »

I have looked at RTB for help already, but even a simple piece of code is somewhat complicated without some explanation.  What makes it more complicated  is that I have found you have many packages within RTBH_support that control more things, so figuring out everything from code is a long shot without some level of guidance.

Also, GET has its limits, and it doesn't help with how to read files.  Sorry if I'm asking for to much, but it would be nice to have some explanation on how everything is used and fits together.  I'm going to search some more for a tutorial accessible to not TGE owners, but I'm not sure if I will find anything.

I do not need anything server-sided, I've figured that out yesterday. I would like to use the POST method because it would be a lot simpler.

I do not find anything on TDN.

If I use the GET method it would be unsafe, no?

I found this code (haven't tested it with anything yet though), I hope it helps, but I still would rather use the post method.  It is kinda obvious what is going on here.

Code: [Select]
%server = "testServer.com:80";
          %path = "/";
          %script = %path @ "auth.php";
          %upd = new HTTPObject(authObject){};
          %upd.get(%server, %script, %clientparameters);

function authObject::onLine(%this, %line) {

      echo(%line);

}

I found this code (haven't tested it with anything yet though), I hope it helps, but I still would rather use the post method.  It is kinda obvious what is going on here.

Code: [Select]
%server = "testServer.com:80";
          %path = "/";
          %script = %path @ "auth.php";
          %upd = new HTTPObject(authObject){};
          %upd.get(%server, %script, %clientparameters);

function authObject::onLine(%this, %line) {

      echo(%line);

}

Should the path end with a "/"?
It looks like it should being the way I see %script.

I also don't understand how the %clientparameters work. How would a name and value work?

Each thing sent needs a name and value.

Giving me two names and two values for reach would be great.

%clientparameters is actually part of the script that the guy was making, not part of the function.  It just is whatever comes after the ? for the get function on a browser.  Such as test.php?variable=value  Where what is underlined goes into the third part of .get()

%clientparameters is actually part of the script that the guy was making, not part of the function.  It just is whatever comes after the ? for the get function on a browser.  Such as test.php?variable=value  Where what is underlined goes into the third part of .get()
Oh, so it's a GET.

I still need using POST, but GET can still work.
« Last Edit: January 19, 2009, 06:07:44 PM by Kalphiter »

Alright, when I try it, auth.php:

Code: (PHP) [Select]
<?PHP

$quantity = $_GET['name'];




$myFile = "auth.htm";
$fh = fopen($myFile, 'w') or die("Can't open file");
$stringData = "This is a tested parameter: " . $quantity . ".<br/>";
fwrite($fh, $stringData);
fclose($fh);


?>


Code: (Torque) [Select]

%server = "kalphiter.com:80";
%path = "/";
%script = %path @ "auth.php";
%upd = new HTTPObject(authObject){};
%clientparameters = "name=namehere";
%upd.get(%server, %script, %clientparameters);

function authObject::onLine(%this, %line) {

      echo(%line);

}






When executed it returns this, something relating to my host? I'm sure this is just something host-sided.

Code: (HTML) [Select]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://byet.org/web/index.html">here</a>.</p>
</body></html>

I don't know why :(

It seems it's a 302 "error".









Also, in RTHB_support.cs I couldn't help but notice this:
Code: (Torque) [Select]
%this.cmd = "POST "@%this.filePath@" HTTP/1.1\r\nHost: "@%this.site@"\r\nUser-Agent: Torque/1.0\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: "@%contentLength@"\r\n\r\n"@%string@"\r\n";
« Last Edit: January 19, 2009, 11:01:04 PM by Kalphiter »

« Last Edit: January 20, 2009, 07:43:53 PM by Chrono »

It seems like it's a problem with your host.

Thanks for the info.

Still need POST method :)

I've been getting the "this file has moved" error on my site too. Which is odd because it worked fine last year.. D: