SRL Archive - Delphi/FPC Help and Tutorials

PostHTTPPage etc. in delphi


mixster

2008-03-22 13:25:50

Is there anyway to move over the PostHTTPPage/Ex and AddPostVariable into Delphi (or and existing Delphi equivalents) as I'm trying something at the moment and it would make it a lot easier if I could access my website to get some of the info.

mastaraymond

2008-03-22 13:26:44

Indy components..

mixster

2008-03-22 16:34:16

Thank you - got it all setup now only problem is I can't even get it to return a webpage :( Maybe someone can point me in the right direction?

program test;

{$APPTYPE CONSOLE}

uses
SysUtils, IdHTTP;

var
MyHTTP: TIdCustomHTTP;
begin
with MyHTTP do
begin
Connect;
try
WriteLn(Get(''));
ReadLn;
finally
Disconnect;
end;
end;
end.
I know there's no URL in there - I took it out as it points to one of my sites files.

mastaraymond

2008-03-22 18:29:45

From: mixster05
Thank you - got it all setup now only problem is I can't even get it to return a webpage :( Maybe someone can point me in the right direction?

program test;

{$APPTYPE CONSOLE}

uses
SysUtils, IdHTTP;

var
MyHTTP: TIdCustomHTTP;
begin
with MyHTTP do
begin
Connect;
try
WriteLn(Get(''));
ReadLn;
finally
Disconnect;
end;
end;
end.
I know there's no URL in there - I took it out as it points to one of my sites files.

You might want to initialize the object, like you always need to do ;).

MyHTTP := TIdCustomHTTP.Create;

Or something like that? :p

mixster

2008-03-22 19:02:38

I was using Create before but it was causing me problems (had even less running than with that) but I'll try again quickly and post up the results.
Edit: I've gotten a little closer now (Was just using MyHTTP.Create and not assigning it to TIdCustomHTTP.Create ><) only now I'm getting an exception as it wants a host =/ who knew it could be so hard just to get it to return a webpage.

Markus

2008-03-23 06:11:13

Use TIdHTTP?

mastaraymond

2008-03-23 07:02:49

From: mixster05
I was using Create before but it was causing me problems (had even less running than with that) but I'll try again quickly and post up the results.
Edit: I've gotten a little closer now (Was just using MyHTTP.Create and not assigning it to TIdCustomHTTP.Create ><) only now I'm getting an exception as it wants a host =/ who knew it could be so hard just to get it to return a webpage.

It's not hard, once you know how to work with Delphi objects everything is quite easy ;)

mixster

2008-03-23 09:07:56

From: Markus
Use TIdHTTP?

I'll try that, though I wanted to use custom as it had a few extra features.

And I know it gets a lot easier when you get used to working with objects, but I stemmed from PHP, then a bit of C and lastly some Scar, so object-orientated isn't hard to get my head around, but is hard to get used to (doesn't help when I'm still playing with PHP and scar a lot).

Edit: No need for Connect or Disconnect >< That's what was giving me problems. I only did that the first time as I was following the example in the pdf help.