使用 IDhttp POST 数据的问题,100分送上! ( 积分: 100 )

9

99koo

Unregistered / Unconfirmed
GUEST, unregistred user!
看了许多IDHTTP使用的例子,学着做了一个登陆论坛的程序,但总不成功,不知道错在哪里,请高手指教!小弟在线等! 请务必调通并给处正确代码,贴资料的还是算了!

var
url,html,sid : string;
**** : tstringstream;
ipos : integer;
Params: TStringStream;
aStream : TMemoryStream;
begin
aStream := TMemoryStream.Create;
**** := tstringstream.Create('');
IdHTTP1.AllowCookies := true;
idhttp1.get('http://www.8da.cc/logging.php?action=login',****);
ipos := pos('sid=',****.DataString);
if ipos >0 then
sid := copy(****.DataString,ipos+4,6);
//showmessage(sid);
memo2.Clear;
memo2.lines.Add('formhash='+sid);
memo2.lines.Add('referer='+'http://www.8da.cc/logging.php?action=login');
memo2.lines.Add('loginmode='+'normal');
memo2.lines.Add('styleid='+'1');
memo2.lines.Add('cookietime='+'86400');
memo2.lines.Add('username='+'woshiaqiang');
memo2.lines.Add('password='+'820104');
memo2.lines.Add('questionid='+'0');
memo2.lines.Add('answer='+'123');

idhttp1.ProtocolVersion := pv1_1;
IdHTTP1.Request.Referer:='http://www.8da.cc/logging.php?action=login';
IdHTTP1.Request.Accept :='image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*';
IdHTTP1.Request.AcceptLanguage := 'zh-cn';
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP1.Request.AcceptEncoding := 'gzip, deflate';
IdHTTP1.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)';
IdHTTP1.Request.Host := 'www.8da.cc';
IdHTTP1.Request.Connection := 'Keep-Alive';
IdHTTP1.Request.CacheControl := 'no-cache';


url := 'http://www.8da.cc/logging.php?action=login' ;
try
html := idhttp1.Post(url,memo2.lines);
except
showmessage('error');
exit;
end;
memo1.Text := html;
end;
 
看了许多IDHTTP使用的例子,学着做了一个登陆论坛的程序,但总不成功,不知道错在哪里,请高手指教!小弟在线等! 请务必调通并给处正确代码,贴资料的还是算了!

var
url,html,sid : string;
**** : tstringstream;
ipos : integer;
Params: TStringStream;
aStream : TMemoryStream;
begin
aStream := TMemoryStream.Create;
**** := tstringstream.Create('');
IdHTTP1.AllowCookies := true;
idhttp1.get('http://www.8da.cc/logging.php?action=login',****);
ipos := pos('sid=',****.DataString);
if ipos >0 then
sid := copy(****.DataString,ipos+4,6);
//showmessage(sid);
memo2.Clear;
memo2.lines.Add('formhash='+sid);
memo2.lines.Add('referer='+'http://www.8da.cc/logging.php?action=login');
memo2.lines.Add('loginmode='+'normal');
memo2.lines.Add('styleid='+'1');
memo2.lines.Add('cookietime='+'86400');
memo2.lines.Add('username='+'woshiaqiang');
memo2.lines.Add('password='+'820104');
memo2.lines.Add('questionid='+'0');
memo2.lines.Add('answer='+'123');

idhttp1.ProtocolVersion := pv1_1;
IdHTTP1.Request.Referer:='http://www.8da.cc/logging.php?action=login';
IdHTTP1.Request.Accept :='image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*';
IdHTTP1.Request.AcceptLanguage := 'zh-cn';
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP1.Request.AcceptEncoding := 'gzip, deflate';
IdHTTP1.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)';
IdHTTP1.Request.Host := 'www.8da.cc';
IdHTTP1.Request.Connection := 'Keep-Alive';
IdHTTP1.Request.CacheControl := 'no-cache';


url := 'http://www.8da.cc/logging.php?action=login' ;
try
html := idhttp1.Post(url,memo2.lines);
except
showmessage('error');
exit;
end;
memo1.Text := html;
end;
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
822
SUNSTONE的Delphi笔记
S
顶部