SRL Archive - Help

How does PostHTTPPage work?


Mat

2012-03-18 13:24:39

Yea, I'm trying to figure out how to make it post to a page.
Thanks
Mat

Sex

2012-03-18 13:30:51

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

2012-03-18 13:45:14

Like this?

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

Sex

2012-03-18 13:50:11

From: Mat
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

2012-03-18 14:00:36

I get a error with:
Client := InitializeHTTPClient(False); and I'm still unsure what the Post is posting, as such.

Sex

2012-03-18 14:08:04

From: Mat
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

2012-03-18 14:09:04

[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

2012-03-18 14:10:39

SRL overrides it, use Wrap instead.

Sex

2012-03-18 14:11:14

I get no errors with the code I posted…what version of Simba are you using?

Edit: Nevermind.

Mat

2012-03-18 14:11:49

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

2012-03-18 14:14:21

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?

Gu3st...

2012-03-18 14:15:32

From: Mat
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