zoukankan      html  css  js  c++  java
  • 待验证的api接口Delphi 6 调用

    use msxml

    Delphi 6 里idhttp貌似没有Header里的一些东西的处理方法。也是摸索了很久,记录一下。

    function HttpRequest(http: TIdHttp; strUrl: string; inStr: string; var outStr, Errmsg: string): boolean;
    var
        HttpReq:IXMLHttpRequest;
    begin
        Result := false;
        try
            HttpReq := CoXMLHTTPRequest.Create;
            HttpReq.open('Post', strUrl, False, EmptyParam, EmptyParam);
            HttpReq.setRequestHeader('Accept', 'application/json; charset=utf-8');
            HttpReq.setRequestHeader('Authorization','26CEECF313091306');
            HttpReq.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
            HttpReq.send((inStr));
            outStr := (HttpReq.responseText);
            result := true;
        except
            on E: Exception do
            begin
                Errmsg := '接口调用错误:'+ #13#10 + E.Message;
                WriteLog(Errmsg);
            end;
        end;
        {
        with http do
        begin
            lstParam := TStringlist.Create;
            lstStream := TStringStream.Create('');
            try
                try
                    lstParam.Add(UTF8Encode(inStr));
                    Post(strUrl, lstParam, lstStream);
                    outStr := Utf8Decode(lstStream.DataString);
                    Result := True;
                except
                    on E: Exception do
                    begin
                        Errmsg := '接口调用错误:'+ #13#10 + E.Message;
                        WriteLog(Errmsg);
                    end;
                end;
            finally
                lstParam.Free;
                lstStream.Free;
            end;
        end;
        }
    end;
  • 相关阅读:
    probuf了解
    rebbitmq-RPC(C#)
    获取指定数量的有序列表
    RPC(Remote Procedure Call Protocol)
    正则表达式(c#)
    02_python函数
    01_python基础
    养生茶
    测试左右移浅淡
    python类的组合
  • 原文地址:https://www.cnblogs.com/adsoft/p/14792965.html
Copyright © 2011-2022 走看看