请求地址:/v5/Contracts/signed.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/signed.json', //api路径
}
var objParam = {
'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'){
requestGet(objUrl,objParam);
}else{
requestPost(objUrl,objParam);
}
}
console.log('Hello,www.APIStore.cn');
getContent('POST');