This is an old revision of the document!


For newbies like me, here's how to connect to a web server to either download a page, or send data through a GET call:

uses
  SysUtils,Classes,httpsend,synacode;
 
var
  sl : TStringList;
  data : String;
 
begin
  //Encode input to handle unauthorized characters
  data := 'name=' + ParamStr(1);
  data := data + '&' + 'number=' + ParamStr(2);
  data := data + '&' + 'date=' + ParamStr(3);
  data := data + '&' + 'time=' + ParamStr(4);
  data := EncodeURL(data);
  //WriteLn = console application; Use ShowMessage() for GUI application  
  WriteLn(data);
 
  sl := TStringList.Create;
  with THTTPSend.Create do
  begin
    if HttpGetText('http://localhost/input.php?' + data,sl) then
    try
      WriteLn(sl.text);
    except
      WriteLn('Cannot get');
    end;
    sl.Free;
    Free;
  end;
end.
public/howto/httpgetpage.1196429456.txt.gz · Last modified: 2010/08/18 11:39 (external edit)
Driven by DokuWiki Recent changes RSS feed