不知道怎么回事,传一个参数时正常,但串俩是会报错400.
请各位帮忙解决一下分不够可以再加谢谢.
传俩参数的代码:procedure TFrmMain.btnLoginClick(Sender: TObject);
var
resParams: TStringStream;
postParams: TStringList;
begin
btnLogin.Enabled := False;
resParams := TStringStream.Create('');
postParams := TStringList.Create;
try
mmLog.Lines.Clear;
IdHTTP.Request.CacheControl :='no-cache';
IdHTTP.Request.Connection :='Keep-Alive';
IdHTTP.Request.Accept :='text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
IdHTTP.Request.ContentType :='application/x-www-form-urlencoded';
IdHTTP.Request.AcceptCharSet := 'UTF-8';
IdHTTP.Request.AcceptEncoding := 'UTF-8';
IdHTTP.Request.AcceptLanguage := 'UTF-8';
IdHTTP.HandleRedirects :=True; //允许重定向,因为这个站点会发生重定向
IdHTTP.AllowCookies :=True;
IdHTTP.HTTPOptions :=[hoForceEncodeParams];
postParams.Clear;
postParams.Add('account=帐号');
postParams.Add('password=密码');//把这个注释了传1个参数就没问题!!!奇怪、?
//postParams.Add('url=/console/remote/');
resParams.WriteString('');
IdHTTP.Request.Referer :='https://sunlogin.oray.com/passport/login?lang=zh_CN'; //设置来路,此网站要求
IdHTTP.Post('https://sunlogin.oray.com/passport/login?lang=zh_CN',postParams,resParams);
mmLog.Lines.Add(Utf8ToAnsi(resParams.DataString));
finally
resParams.Free;
postParams.Free;
btnLogin.Enabled := True;
end;
end;
请各位帮忙解决一下分不够可以再加谢谢.
传俩参数的代码:procedure TFrmMain.btnLoginClick(Sender: TObject);
var
resParams: TStringStream;
postParams: TStringList;
begin
btnLogin.Enabled := False;
resParams := TStringStream.Create('');
postParams := TStringList.Create;
try
mmLog.Lines.Clear;
IdHTTP.Request.CacheControl :='no-cache';
IdHTTP.Request.Connection :='Keep-Alive';
IdHTTP.Request.Accept :='text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
IdHTTP.Request.ContentType :='application/x-www-form-urlencoded';
IdHTTP.Request.AcceptCharSet := 'UTF-8';
IdHTTP.Request.AcceptEncoding := 'UTF-8';
IdHTTP.Request.AcceptLanguage := 'UTF-8';
IdHTTP.HandleRedirects :=True; //允许重定向,因为这个站点会发生重定向
IdHTTP.AllowCookies :=True;
IdHTTP.HTTPOptions :=[hoForceEncodeParams];
postParams.Clear;
postParams.Add('account=帐号');
postParams.Add('password=密码');//把这个注释了传1个参数就没问题!!!奇怪、?
//postParams.Add('url=/console/remote/');
resParams.WriteString('');
IdHTTP.Request.Referer :='https://sunlogin.oray.com/passport/login?lang=zh_CN'; //设置来路,此网站要求
IdHTTP.Post('https://sunlogin.oray.com/passport/login?lang=zh_CN',postParams,resParams);
mmLog.Lines.Add(Utf8ToAnsi(resParams.DataString));
finally
resParams.Free;
postParams.Free;
btnLogin.Enabled := True;
end;
end;
解决方案 »
- delphi下dll中调用dll如何发布到别的机器也能正常运行?
- 如何判断-----------------一个日期是否在两个日期之间?
- 关于对adoconnection控件的connectionstring属性动态赋值的问题。
- 问个DELPHI设置的问题
- 为什么Delphi7的MessageDLG()的按钮是英文文字?
- 如何向Listview中加入数据库信息?求教...
- 一个字段却要占用整个dbgrid 的宽度......
- 为什么我用RichEdit做的编辑器无法运行?
- 我是新手:ADO 问题?
- 在Delphi6中,调用Outlook Express时如何加上附件,如能解决高分相送!
- 求购Delphi7从入门到精通
- 这个代码如何改?--------------关于取得文件夹下的文件清单?
postParams.Add('&password=密码');