<del id="37dnz"></del>
<cite id="37dnz"><span id="37dnz"><cite id="37dnz"></cite></span></cite>
<var id="37dnz"></var>
<thead id="37dnz"><video id="37dnz"><listing id="37dnz"></listing></video></thead>
<cite id="37dnz"><span id="37dnz"><var id="37dnz"></var></span></cite>
<cite id="37dnz"></cite>
<menuitem id="37dnz"><video id="37dnz"><thead id="37dnz"></thead></video></menuitem>
<cite id="37dnz"></cite>
<cite id="37dnz"><span id="37dnz"><var id="37dnz"></var></span></cite>
<ins id="37dnz"><span id="37dnz"></span></ins>
<cite id="37dnz"><noframes id="37dnz"><var id="37dnz"></var><menuitem id="37dnz"></menuitem><ins id="37dnz"></ins>
<ins id="37dnz"><span id="37dnz"></span></ins>
<ins id="37dnz"></ins>
<cite id="37dnz"></cite>
<ins id="37dnz"></ins>
<cite id="37dnz"><video id="37dnz"><cite id="37dnz"></cite></video></cite>
<cite id="37dnz"></cite>
<cite id="37dnz"></cite>
<cite id="37dnz"><span id="37dnz"></span></cite><ins id="37dnz"></ins>
<var id="37dnz"><video id="37dnz"><menuitem id="37dnz"></menuitem></video></var>
<var id="37dnz"><span id="37dnz"></span></var>
<thead id="37dnz"></thead>
<cite id="37dnz"><span id="37dnz"><var id="37dnz"></var></span></cite>
<cite id="37dnz"><span id="37dnz"></span></cite>
<ins id="37dnz"><span id="37dnz"><cite id="37dnz"></cite></span></ins>
<cite id="37dnz"><span id="37dnz"><var id="37dnz"></var></span></cite><ins id="37dnz"><span id="37dnz"><var id="37dnz"></var></span></ins>
<menuitem id="37dnz"><video id="37dnz"><thead id="37dnz"></thead></video></menuitem>
<cite id="37dnz"></cite>
<noframes id="37dnz"><progress id="37dnz"><dl id="37dnz"></dl></progress>
<ins id="37dnz"><span id="37dnz"><cite id="37dnz"></cite></span></ins>
<listing id="37dnz"><dl id="37dnz"><progress id="37dnz"></progress></dl></listing>
热门搜索 : OCR识别   工商信息   所有产品
首页 > 文档中心 > NodeJS示范代码
/*
 * 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: 'v.apistore.cn',	//主机名
        path: '/api/c94',	//api路径
    }
    var objParam = {
        'key' : '您申请的key,在会员中心->?#19994;?#25968;据->对应数据的下方',
'image' : '',

    }

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

console.log('Hello,www.wzpj.tw');
getContent('POST');

现在注册,免费试用所有接口

免费注册
山西十一选五走势图 皇冠篮球比分90vs 青海快三基本走势图 彩票规则 体育彩票百变王牌 七走势图带连线走势图 山东体彩十一运夺金开奖结果查询 陕西20选5开奖结果查询结果 极速时时彩75秒开奖 四川快乐12投注技巧 安徽11选5 彩票开发 大乐透19071新浪 开心网七星彩彩票论坛 香港生肖时时彩微信 码报生肖卡