这是代码:
// Article Summary
var params = {
host: 'api.smmry.com',
path: '/',
body: {
SM_API_KEY: 'B...',
SM_URL: 'www.bbc.com/sampleNews'
}
};
http.get(params, function(res) {
res.on('data', function(data) {
console.log(JSON.parse(data.toString()));
});
});
我正在尝试提供有效的API请求,但无法提供。试图以这种方式提供数据:
var params = {
host: 'api.smmry.com',
path: '/',
SM_API_KEY: 'B...',
SM_URL: 'www.bbc.com/sampleNews'
};
尝试:
var params = {
host: 'api.smmry.com',
path: '/',
data: {
SM_API_KEY: 'B...',
SM_URL: 'www.bbc.com/sampleNews'
}
};
我得到的错误:
{ sm_api_error: 1, sm_api_message: 'INSUFFICIENT VARIABLES' }
答案 0 :(得分:0)
我做到了这一点并且有效:
var params = {
host: 'api.smmry.com',
path: '/&SM_API_KEY=B...&SM_URL=' + url,
method: 'POST'
};
var req = http.request(params, function(res) {
res.on('data', function(data) {
console.log(JSON.parse(data.toString()));
});
res.on('end', function() {
console.log('No more data in response.');
});
});