forked from nswbmw/node-wechat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example2.js
54 lines (51 loc) · 2.58 KB
/
example2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var http = require('http'),
wechat = require('node-wechat')(your_token);
http.createServer(function (req, res) {
//检验 token
wechat.checkSignature(req, res);
//预处理
wechat.handler(req, res);
//链式监听
wechat.text(function (data) {
// TODO
}).image(function (data) {
// TODO
}).location(function (data) {
// TODO
}).link(function (data) {
// TODO
}).event(function (data) {
// TODO
}).voice(function (data) {
// TODO
}).video(function (data) {
// TODO
}).all(function (data) {
var msg = {
FromUserName : data.ToUserName,
ToUserName : data.FromUserName,
//MsgType : "news",
Articles : [
{
Title: "习近平印尼国会演讲 向现场观众问好:阿巴嘎坝",
Description: "央广网雅加达10月3日消息 北京时间3日上午11时许,正在印度尼西亚进行国事访问的中国国家主席习近平,在印尼国会发表重要演讲,阐述如何进一步促进双边关系、中国与东盟关系发展的构想,以及中国和平发展的理念。",
PicUrl: "http://news.cnr.cn/special/xjp4/zb/zy/201310/W020131003454716456595.jpg",
Url: "http://news.cnr.cn/special/xjp4/zb/zy/201310/t20131003_513743132.shtml"
},
{
Title: "九寨沟:少数游客拦车翻栈道致交通瘫痪",
Description: "10月2日,九寨沟发生大规模游客滞留事件。因不满长时间候车,部分游客围堵景区接送车辆,导致上下山通道陷入瘫痪。大批游客被迫步行十几公里下山,包括80岁老人及9个月小孩。入夜后,游客围住售票处要求退票,并一度“攻陷”售票处。10月3日凌晨,九寨沟管理局、阿坝大九旅集团九寨沟旅游分公司发致歉书向游客致歉。",
PicUrl: "http://www.chinadaily.com.cn/dfpd/shehui/attachement/jpg/site1/20131003/a41f726719b213b7156402.jpg",
Url: "http://www.chinadaily.com.cn/dfpd/shehui/2013-10/03/content_17008311.htm"
},
{
Title: "美政府关门第二天 官民高呼“伤不起”",
Description: "中新社华盛顿10月2日电 (记者 张蔚然)美国政府“关门”进入第二天,白宫与国会对峙僵局未破,美国继续在“喊话”模式中运转。越来越多的联邦部门和民众都在抱怨“伤不起”,调门越喊越高。",
PicUrl: "http://i1.hexunimg.cn/2013-10-03/158486762.jpg",
Url: "http://www.chinanews.com/gj/2013/10-03/5343908.shtml?f=baidu"
}
]
}
wechat.send(msg);
});
}).listen(80);