电子合同API开发文档 v5

签署合同-自定义签署

请求地址:/v5/Contracts/signed.json

请求方式:POST

接口版本: 5.2.3

接口描述:

program APIStore;
{*
本范例在Delphi XE10.1下编译通过,依赖Indy10组件
*}
{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils, System.Classes,
  IdHTTP,idURI;

{*
POST请求方式(推荐)
url 请求地址
param 请求参数
*}
procedure requestPost(url:string; param:string);
var
  pHttp: TIdHTTP;

  requestStream : TStringStream;  //请求数据流
  responseStream : TStringStream; //返回信息
  responseStr : string;
begin
  requestStream := TStringStream.Create('',TEncoding.UTF8);
  responseStream := TStringStream.Create('',TEncoding.UTF8);
  pHttp := TIdHTTP.Create(Nil);
  try
    try
      phttp.Request.ContentType:='application/x-www-form-urlencoded';
      phttp.Request.CharSet := 'UTF-8';
      requestStream.WriteString(param);   //以流的方式提交参数

      pHttp.Post(url,requestStream,responseStream);

      responseStr := responseStream.DataString;    //获取网页返回的信息
      //responseStr := UTF8Decode(responseStr);
      writeln(responseStr);
    except
      on e : Exception do
       begin
        writeln(e.Message);
      end;
    end;
  finally
    phttp.Free;
    requestStream.Free;
    responseStream.Free;
  end;
end;

{*
GET请求方式
url 请求地址
param 请求参数
*}
procedure requestGet(url:string; param:string);
  var
  pHttp: TIdHTTP;
  responseStream : TStringStream; //返回信息
  responseStr : string;
begin
  responseStream := TStringStream.Create('',TEncoding.UTF8);
  pHttp := TIdHTTP.Create(Nil);
  try
    try
      pHttp.Get(url + '?' + param,responseStream);
      responseStr := responseStream.DataString;    //获取网页返回的信息
      //responseStr := UTF8Decode(ResponseStr);
      writeln(responseStr);
    except
      on e : Exception do
       begin
        writeln(e.Message);
      end;
    end;
  finally
    phttp.Free;
    responseStream.Free;
  end;
end;


//获取内容
procedure getContent(requestType:string);
var
  url:string;
  reg:string;
  pwd:string;
  param:string;
begin
   url:="https://api-v2.1dq.com/v5/Contracts/signed.json";
 param:="easy_id=175592531139104768&signed_data=[ {
        "seal_id": "必填-印章id",
	"page": "第几页如2",
	"x": "必填-需要盖章的x坐标位置",
        "y": "必填-需要盖章的y坐标位置"
    }
,{ "seal_id": "abf447a8-ad71-11ea-b95e-0242ac320a0c", "page": "1", "x": "200", "y": "200" }, { "seal_id": "abf447a8-ad71-11ea-b95e-0242ac320a0c", "page": "6", "x": "200", "y": "200" }]&words_id=2c6084c0-ad71-11ea-9664-0242ac320a0c&certification_code=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9&certification_type=mobile&cross_page_data=[ { "seal_id": "abf447a8-ad71-11ea-b95e-0242ac320a0c", "y": "100" },{
        "seal_id": "必填-印章id",
        "y": "必填-需要盖章的y坐标位置"
    } ]&page_width=800";

  if requestType = 'GET' then
  begin
      requestGet(url,param);
  end
  else
  begin
      requestPost(url,param);
  end;
end;