不好意思 今天才收到信上线!
你把信箱给我,我发给你!
下面是简单的介绍:
首先在Form上放idHttp, IdCookieManager,并将两者联系在一起
(通过idHttp的CookieManager),剩下的 你就专心实现你要完成
的东西就可以啦。
不知道你玩过KOK没有,下面的代码是登陆KOK注册页面的部分代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, IdCookieManager, IdBaseComponent,
IdComponent, IdTCPConnection, IdTCPClient, IdHTTP;
type
TForm1 = class(TForm)
http: TIdHTTP;
CookieMngr: TIdCookieManager;
edtUserName: TLabeledEdit;
edtPassword: TLabeledEdit;
btnLogin: TButton;
Cookies: TMemo;
Memo1: TMemo;
btnInfor: TButton;
Button1: TButton;
edtSN: TLabeledEdit;
procedure btnLoginClick(Sender: TObject);
procedure btnInforClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
//这个函数是登陆页面,
procedure TForm1.btnLoginClick(Sender: TObject);
var
s, s1: TStringStream;
i: Integer;
begin
s := TStringStream.Create('');
s1 := TStringStream.Create('');
try
//{
s.WriteString('action=LOGIN&gameSelect=gkk&');
s.WriteString('acct=' + edtUserName.Text + '&');
s.WriteString('pwd=' + edtPassword.Text);
http.Request.ContentType := 'application/x-www-form-urlencoded';
try
http.Post('http://register.kok.com.cn/billing/servlet/walletServlet', s, s1)
except
http.Get(http.Response.Location, s1);
end;
//}
Memo1.Lines.Text := s1.DataString;
//下面的是显示cookies信息的代码
Cookies.Clear;
for i := 0 to CookieMngr.CookieCollection.Count - 1 do
Cookies.Lines.Add(CookieMngr.CookieCollection.Items.CookieText);
finally
s.Free;
s1.Free;
end;
end;
//这是KOK注册页面中,显示帐户信息的函数
procedure TForm1.btnInforClick(Sender: TObject);
var
s, s1: TStringStream;
i: Integer;
begin
{
<form action=../servlet/walletServlet method=post>
<input type=submit value="修改个人资料">
<input type=hidden name=action value=INFO>
</form>
}
s := TStringStream.Create('');
s1 := TStringStream.Create('');
try
s.WriteString('action=INFO');
http.Request.ContentType := 'application/x-www-form-urlencoded';
try
http.Post('http://register.kok.com.cn/billing/servlet/walletServlet', s, s1)
except
http.Get(http.Response.Location, s1);
end;
Memo1.Lines.Text := s1.DataString;
Cookies.Clear;
for i := 0 to CookieMngr.CookieCollection.Count - 1 do
Cookies.Lines.Add(CookieMngr.CookieCollection.Items.CookieText);
finally
s.Free;
s1.Free;
end;
end;
end.