使用Node JS从模板发送批量短信
使用带有Node JS的模板将批量SMS发送到一组联系人
Node JS : API文档
使用Node JS从模板发送批量短信
var aclass = "sms";
var method = "sendsmstogroupfromtemplate";
var user = "user";
var password = "password";
var countrycode = "34";
var idgroup = "1";
var idtemplate = "1000";
var scheduledatetime = "";
var output = "";
const https = require('https')
const options = {
hostname: 'afilnet.com',
port: 443,
path: '/api/http/?class='+aclass+'&method='+method+'&user='+user+'&password='+password+'&countrycode='+countrycode+'&idgroup='+idgroup+'&idtemplate='+idtemplate+'&scheduledatetime='+scheduledatetime+'&output='+output,
method: 'GET'
}
const req = https.request(options, res => {
res.on('data', d => {
// Do something
})
})
req.on('error', error => {
console.error(error)
})
req.end()
var aclass = "sms";
var method = "sendsmstogroupfromtemplate";
var user = "user";
var password = "password";
var countrycode = "34";
var idgroup = "1";
var idtemplate = "1000";
var scheduledatetime = "";
var output = "";
const https = require('https')
const options = {
hostname: 'afilnet.com',
port: 443,
path: '/api/http/?class='+aclass+'&method='+method+'&user='+user+'&password='+password+'&countrycode='+countrycode+'&idgroup='+idgroup+'&idtemplate='+idtemplate+'&scheduledatetime='+scheduledatetime+'&output='+output,
method: 'POST'
}
const req = https.request(options, res => {
res.on('data', d => {
// Do something
})
})
req.on('error', error => {
console.error(error)
})
req.end()
参数 | 描述 | 必修/可选 |
---|---|---|
class=sms | 要求的课程:要求的课程 | 必修 |
method=sendsmstogroupfromtemplate | 请求的类方法:发出请求的类的方法 | 必修 |
user | 您的Afilnet帐户的用户和电子邮件 | 必修 |
password | 您的Afilnet帐户的密码 | 必修 |
countrycode | 国家代码 | 必修 |
idgroup | 目标组ID | 必修 |
idtemplate | 范本编号 | 必修 |
scheduledatetime | 交货日期和时间,格式为yyyy-mm-dd hh:mm:ss | 可选的 |
output | 结果的输出格式 | 可选的 |
发出请求时,您将收到以下字段:
- status
-
结果(如果status = success),您将在此处收到以下值:
- id
- count
- credits
-
destinations
- messageid
- destination
- 错误(如果status = error),在这里您将收到错误代码
下面列出了可能的错误代码
码 | 描述 |
---|---|
MISSING_USER | 不包括用户或电子邮件 |
MISSING_PASSWORD | 不包含密码 |
MISSING_CLASS | 不包括课程 |
MISSING_METHOD | 不包括方法 |
MISSING_COMPULSORY_PARAM | 不包括强制参数 |
INCORRECT_USER_PASSWORD | 用户或密码错误 |
INCORRECT_CLASS | 班级不正确 |
INCORRECT_METHOD | 方法不正确 |
NOT_ACCESS_TO_GROUP | 不允许您进入指定的组 |
NO_CREDITS | 您的余额不足 |
参数:
- class : sms
- method : sendsmstogroupfromtemplate
- user : user
- password : password
- countrycode : 34
- idgroup : 1
- idtemplate : 1000
- scheduledatetime :
- output :
请求:
https://www.afilnet.com/api/http/?class=sms&method=sendsmstogroupfromtemplate&user=user&password=password&countrycode=34&idgroup=1&idtemplate=1000&scheduledatetime=&output=