本文整理自网络,侵删。
uses IdSSLOpenSSL,idhttp;function HttpsAuthGet(Url, Username, Password: string):string;var ssl: TIdSSLIOHandlerSocketOpenSSL; http: TIdHTTP;begin http := TIdHttp.Create(nil); try ssl := TIdSSLIOHandlerSocketOpenSSL.Create(nil); try http.IOHandler := ssl; http.Request.BasicAuthentication:=True; http.Request.Username := Username; http.Request.Password := Password; Result:=http.Get(Url); if (http.ResponseCode<200) or (http.ResponseCode>=300) then raise Exception.Create(http.ResponseText); finally FreeAndNil(ssl); end; finally FreeAndNil(http); end;end;
相关阅读 >>
Delphi 获取随机字符串的方法 thash.getrandomstring
Delphi 条件编译语法 $ifdef $else $endif
Delphi d10.x 在android 9及更高版本下使用Delphi获取设备序列号?
Delphi 全局变量 hinstance 到底是在什么时候赋值的?
更多相关阅读请进入《Delphi》频道 >>