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;
  try
    if HttpGetText('http://localhost/input.php?' + data,sl) then
      WriteLn(sl.text)
    else
      WriteLn('Cannot get');
  finally
    sl.Free;
  end;
end.
public/howto/httpgetpage.txt · Last modified: 2010/08/18 11:39 by frantic
Driven by DokuWiki Recent changes RSS feed