NodeParty 自动发短信程序
不错,是自动发的。
刚刚报名明天nodeparty的朋友都收到短信了,我是自动发的。
下面是源码。
'use strict';
var assert = require('assert');
var Weimi = require('weimi');
var config = require('../config.json');
var data = require('../11th.json');
var _ = require('lodash');
var Q = require('q');
describe('#Notify SMS', function() {
this.timeout(120000);
it('should send out a sms', function(done) {
var sms = new Weimi({
uid: config.uid,
pas: config.pas
});
var arrs = [];
_.each(data.rows, function(val, index) {
arrs.push(sms.sendMessage({
cid: config.cid,
mobile: val.F3,
content: '晚上好, ' + (val.FNAME ? val.FNAME : val.F1) + '。请明天下午来参加NodeParty。1:00PM ~ 5:30PM。地点:http://j.map.baidu.com/RNjI8'
}));
});
Q.allSettled(arrs)
.then(function(results) {
var err;
results.forEach(function(result) {
if (result.state === "fulfilled") {
var value = result.value;
} else {
var reason = result.reason;
err = new Error(reason);
}
});
if (err)
done(err);
done();
});
});
});
package.json
{
"name": "node-party-sms",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"test": "test"
},
"dependencies": {
"excel": "^0.1.4",
"lodash": "^4.0.0",
"log4js": "^0.6.29",
"node-xlsx": "^0.6.0",
"q": "^1.4.1",
"weimi": "^1.0.1",
"xlsx": "^0.8.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "hailiang.hl.wang@gmail.com",
"license": "ISC"
}
发短信的模块在这里: https://www.npmjs.com/package/weimi