unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP;
type
TForm2 = class(TForm)
IdHTTP1: TIdHTTP;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
const
VOID = '';
function Explode(Ch: Char; s: string; Index: Byte): string;
type
TTableString = array of string;
function InternalExplode(Str: string; Divider: Char): TTableString;
var
i, j: Integer;
begin
j := 1;
i := 1;
while i <= Length(Str) do
begin
if (Str[i] = Divider) or (i = Length(Str)) then
begin
if (i = Length(Str)) and (Str[i] <> Divider) then
Inc(i);
SetLength(Result, High(Result) + 2);
Result[High(Result)] := Trim(Copy(Str, j, i - j));
j := i + 1;
end;
Inc(i);
end;
end;
begin
Result := InternalExplode(s, ch)[index];
end;
procedure TForm2.Button1Click(Sender: TObject);
var
source: String;
answer: TStringStream;
result: String;
begin
source:='/appsvc/appmsg_ver8.asp?fmnumber=1234567&fmt=&lastmsg=1&version=8.0.0.7669';
answer:=TStringStream.Create(VOID);
IdHTTP1.ProtocolVersion:=pv1_1;
IdHTTP1.Request.Host:='appmsg.gadu-gadu.pl';
IdHTTP1.Request.AcceptLanguage:='pl';
IdHTTP1.Request.ContentType:='application/x-www-form-urlencoded';
IdHTTP1.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 5.0; Windows NT)';
IdHTTP1.Request.Pragma:='no-cache';
IdHTTP1.Get(source, answer);
IdHTTP1.Free;
answer.Free;
result := answer.DataString;
if result[Length(result)] = #10 then
Delete(result, Length(result), 1);
if result = 'notoperating' then
result := VOID
else
result := Explode(' ', result, 3);
end;
end.
Program się kompiluje i na końcu wywala error "Unknown protocol." Co robię nie tak? Kod praktycznie w całości "zerżnąłem" z HGG więc tym bardziej mnie to dziwi ;/