本文整理自网络,侵删。
var IdHTTP1:TIdHTTP; postStream : TStringStream; Wstr:WideString;<br><br>res:WideString;begin IdHTTP1 := TidHTTp.create(nil); try Wstr:= 'aaccount=' + aaccount; Wstr:=Wstr+'&'+'passwd=' +passwd; postStream:=TStringStream.Create(ansitoUTF8(Wstr)); IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded'; try res:=Utf8ToAnsi(IdHTTP1.Post(infoURl,postStream)); except on E:Exception do begin MsgBox('错误信息:' +e.message); end; end; vJson := SO(res); end;
用stringlistPOST提交时会乱码,改用该方法后解决。
相关阅读 >>
Delphi 从twebbrowser webbrowser得到全部html源码
Delphi 检查字符串是不是 包含 中文和获取中文字符个数
winapi 字符及字符串函数(11): lstrcpyn - 复制字符串, 同时指定要复制的长度
更多相关阅读请进入《Delphi》频道 >>