首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

求idhttp post事例

2013-01-05 
求idhttp post例子找了半天没有post例子,谁能发个,小弟学习下!!!小弟感激不尽啊!!![解决办法]function Log

求idhttp post例子
找了半天没有post例子,谁能发个,小弟学习下!!!

小弟感激不尽啊!!!
[解决办法]
function Login(const Username,Password: string): Boolean;
 var
   html :string;
 begin
   Result :=False;
   Account :=UserName;
   
   IndyHttp :=TIdHTTP.Create(nil);
   IndyCookieManager :=TIdCookieManager.Create(nil);
   IndyHttp.CookieManager :=IndyCookieManager;
   IndyZlib :=TIdCompressorZLibEx.Create(nil);
   IndyHttp.Compressor :=IndyZlib;
   PostParams :=TStringList.Create;
   
   IndyHttp.Request.CacheControl :='no-cache';
   IndyHttp.Request.Connection :='Keep-Alive';
   IndyHttp.Request.Accept :='text/html, application/xhtml+xml, */*';
   IndyHttp.Request.ContentType :='application/x-www-form-urlencoded';
   IndyHttp.HandleRedirects :=True;
   IndyHttp.AllowCookies :=True;
   IndyHttp.HTTPOptions :=[hoForceEncodeParams];
 
  IndyHttp.Get('http://192.168.0.1/Default.aspx');
 
  PostParams.Clear;
   PostParams.Add('account='+Username);
   PostParams.Add('password='+Password);
   IndyHttp.Request.Referer :='Referer http://192.168.0.1/Default.aspx';
   html :=IndyHttp.Post('http://192.168.0.1/Login.ashx',PostParams);
   if Pos('{Userinfo:[{result:"1"}]}',html)>0 then   //ajax
     Result :=True;
 end;

热点排行