Log in

View Full Version : How does PostHTTPPage work?



Mat
03-18-2012, 05:24 PM
Yea, I'm trying to figure out how to make it post to a page.
Thanks
Mat

Sex
03-18-2012, 05:30 PM
PostHTTPPage takes 3 parameters. The first one is an integer returned from InitializeHTTPClient. The second one is the URL that you're posting to. The third parameter is the post string such as 'a=b&c=d'.

You should use PostHTTPPageEx and AddPostVariable instead though :).

Mat
03-18-2012, 05:45 PM
Like this?

var
S:string;
begin
S := 'gay';
PostHTTPPageEx(0,'www.loloo.com');
AddPostVariable(0,s,s);
end.
?

Sex
03-18-2012, 05:50 PM
Like this?

var
S:string;
begin
S := 'gay';
PostHTTPPageEx(0,'www.loloo.com');
AddPostVariable(0,s,s);
end.
?

No, PostHTTPPage(Ex) actually posts to the page. You also need InitializeHTTPClient.


var
Client : integer;
begin
Client := InitializeHTTPClient(False);
AddPostVariable(Client, 'gay', 'gay');
postHTTPPageEx(Client, 'www.loloo.com');
FreeHTTPClient(Client);
end.
Would work the same as

var
Client : integer;
begin
Client := InitializeHTTPClient(False);
PostHTTPPage(Client, 'www.loloo.com', 'gay=gay');
FreeHTTPClient(Client);
end.

Mat
03-18-2012, 06:00 PM
I get a error with:
Client := InitializeHTTPClient(False); and I'm still unsure what the Post is posting, as such.

Sex
03-18-2012, 06:08 PM
I get a error with:
Client := InitializeHTTPClient(False); and I'm still unsure what the Post is posting, as such.

What do you mean? It would be helpful if you could tell me the error you are receiving.

Mat
03-18-2012, 06:09 PM
[Error] (8:40): Invalid number of parameters at line 7
Compiling failed.
E:and basiclly I have a website, and I want to post something to it, but I don't like the idea of it being a open post.

Dgby714
03-18-2012, 06:10 PM
SRL overrides it, use Wrap instead.

Sex
03-18-2012, 06:11 PM
I get no errors with the code I posted...what version of Simba are you using?

Edit: Nevermind.

Mat
03-18-2012, 06:11 PM
Simba is released under the GPL license.
You are currently using version: 984
Compiled with FPC version 2.4.4

Please report bugs at: http://bugs.villavu.com/
E:only when i include SRL wt?

Sex
03-18-2012, 06:14 PM
As Dgby said, use InitializeHTTPClientWrap instead.


E:and basiclly I have a website, and I want to post something to it, but I don't like the idea of it being a open post.
What do you mean open post?

Zyt3x
03-18-2012, 06:15 PM
I get a error with:
Client := InitializeHTTPClient(False); and I'm still unsure what the Post is posting, as such.

try
Client := InitializeHTTPClient(False, False);

AddPostVariable will add a post-variable to the web client.
Read more about Post-variables here: https://en.wikipedia.org/wiki/POST_(HTTP) and here
http://en.wikipedia.org/wiki/Post/Redirect/Get