Author Topic: HTTPObject PHP parameters  (Read 2371 times)

Okay, from the beginning. I am locally hosting a website and I have a PHP script which contains this:
Code: (PHP) [Select]
<?php
    file_put_contents
("./stuff.txt",$_GET["variable"]);
?>


And then in TS, I do this:
Code: (TorqueScript) [Select]
new HTTPObject(Intrastuff);
Intrastuff.get("localhost:80","/filename.php?variable=nothing");

Okay, on the server, before running the TS code, there is no file except filename.php
Now I run the TS code, and a file called stuff.txt is created. I open it, and the contents are just blank, "".
I tried making it echo the $_GET["variable"], but its still just "". I'm guessing this is a problem with TS.

How would I properly send a request of the PHP script, but passing arguments?

Also, HTTPObjects have a .post function, but the arguments dont make sense.
.post(Address, RequestURI, query, post);

Bump due to great importance.

I think you should try TCP sockets

When trying your code, I got this:
GET /filename.php?variable=nothing
This seems to correct, try checking the response first by declaring this function right after you create the HTTPObject:
Code: (TS) [Select]
function Intrastuff::onLine(%this, %line)
{
    echo(%line);
}

Well, I tried looking at TorquePowered.com, and it seems that TGE has problems encoding the "&" character (before I tried using multiple variables), and if I try stuff like ?variable=nothing&cookies=impossible, then in PHP, the variable 'variable' will contain 'nothing&cookies=impossible'.

Well, I tried looking at TorquePowered.com, and it seems that TGE has problems encoding the "&" character (before I tried using multiple variables), and if I try stuff like ?variable=nothing&cookies=impossible, then in PHP, the variable 'variable' will contain 'nothing&cookies=impossible'.
Try just going to TCPObject.

Matter of fact, I made some functions some time ago for easy packet making. You have to send() whatever these functions return.

Code: [Select]
package Cloud_TCPObjects
{
    function TCPObject::createPostPacket(%this, %host, %path, %data)
    {
    return "POST "@ %path @" HTTP/1.1\r\nHost: "@ %host @"\r\nUser-Agent: Torque/1.0\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: "@ strlen(%data) @"\r\n\n"@ %data;
    }

    function TCPObject::createGetPacket(%this, %host, %path)
    {
    return "GET "@ %path @" HTTP/1.1\r\nHost: "@ %host @"\r\nUser-Agent: Torque/1.0\r\n\r\n";
    }
};

Examples:

Code: [Select]
%packet = %tcp.createGetPacket("google.com", "/lol/asdf.txt");
%tcp.send(%packet);


//Your variable sending with POST
%packet = %tcp.createPostPacket("google.com", "/submit.php", "variable=nothing&cookies=impossible");
%tcp.send(%packet);


//Your variable sending with GET
%packet = %tcp.createGetPacket("google.com", "/submit.php?variable=nothing&cookies=impossible");
%tcp.send(%packet);

I also suggest making these into regular functions, they shouldn't be in every TCPObject like I did.
« Last Edit: October 03, 2010, 01:04:51 AM by Kalphiter »

Why are the functions in a package (Cloud_TCPObjects)?

Why are the functions in a package (Cloud_TCPObjects)?
why not?  :cookieMonster:

Why are the functions in a package (Cloud_TCPObjects)?

Because he is making some kind of mod that is supposed to be better than rtb. I think he just cloned it.

Because he is making some kind of mod that is supposed to be better than rtb. I think he just cloned it.
how do i cloned functions i made

how do i cloned functions i made

I'm just saying. I think you cloned it. Maybe you didn't. idk.

I'm just saying. I think you cloned it. Maybe you didn't. idk.
Please learn what you're talking about first before you spew crap.

Please learn what you're talking about first before you spew crap.
Lol'd. :cookieMonster: