电子合同API开发文档 v5

设置签署位置

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

请求方式:POST

接口版本: 5.2.3

接口描述:

/*
 * post请求方法(推荐)
 * objUrl obj 主机名,路径
 * objParam obj 附加数据对象
 */
function requestPost(objUrl, objParam)
{
    var http = require('http');				//载入https模块
    var qs = require('querystring');		//载入Query String模块
    var fs = require('fs'); 		//载入fs模块读取文件

    var content = qs.stringify(objParam);	//url编码参数

    var options = {
        hostname: objUrl.hostname,
        port: 80,
        path: objUrl.path,
        method: 'POST',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
        }
    };

    var reqCallBack = function (res) {
        console.log('STATUS: ' + res.statusCode);
        console.log('HEADERS: ' + JSON.stringify(res.headers));
        res.setEncoding('utf8');
        res.on('data', function (chunk) {		//有数据时读数据
            console.log('POST返回结果: ' + chunk);
        });
    };

    var req = http.request(options, reqCallBack);
    req.write(content);		//POST方法传输数据
    req.on('error', function (e) {
        console.log('problem with request: ' + e.message);
    });

    req.end();
}

/*
 * get请求方法
 * objUrl obj 主机名,路径
 * objParam obj 附加数据对象
 */
function requestGet(objUrl, objParam)
{
    var http = require('http');				//载入http模块
    var qs = require('querystring');		//载入Query String模块
    var fs = require('fs'); 		//载入fs模块读取文件

    var content = qs.stringify(objParam);	//url编码参数

    var options = {
        hostname: objUrl.hostname,
        port: 80,
        path: objUrl.path + '?' + content,
        method: 'GET'
    };

    var reqCallBack = function (res) {
        console.log('STATUS: ' + res.statusCode);
        console.log('HEADERS: ' + JSON.stringify(res.headers));
        res.setEncoding('utf8');
        res.on('data', function (chunk) {		//有数据时读数据
            console.log('GET返回结果: ' + chunk);
        });
    };

    var req = http.request(options, reqCallBack);

    req.on('error', function (e) {
        console.log('problem with request: ' + e.message);
    });

    req.end();

}


/*
 *
 * @requestType string 请求方式,POST或者GET,推荐POST
 */
function getContent(requestType)
{
    
    var objUrl = {
        hostname: 'api.1dq.com',	//主机名
        path: '/v5/Contracts/positionSign.json',	//api路径
    }
    var objParam = {
        'easy_id' : '175592531139104768',
'position' : '[
    {
        "x": "200",
        "y": "200",
        "page": "第几页",
        "seal_type": "1、普通印章,2、骑缝章",
        "user_type": "类型,1为个人,2为企业",

        "seal_width": "无特殊要求,不用传递,为空默认即可。签署区域宽度",
        "seal_height": "无特殊要求,不用传递,为空默认即可。签署区域高度",
        "area_title": "无特殊要求,不用传递,为空默认即可。签署提示",
        "page_width": "无特殊要求,不用传递,为空默认即可。指定页面宽度",
        "sign_id": "无特殊要求,不用传递,为空默认即可。签署人或填写人id"
    }
]',
'words_id' : '',
'number' : 'test@1dq.com',

    }

    if(requestType == 'GET'){
        requestGet(objUrl,objParam);
    }else{
        requestPost(objUrl,objParam);
    }
}

console.log('Hello,www.APIStore.cn');
getContent('POST');