Last active
June 15, 2016 07:48
-
-
Save LincolnBurrows/30b6d9d448d43f3fbd1f812cb4f2c778 to your computer and use it in GitHub Desktop.
测试wecha-api上传临时素材和永久素材
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var WechatAPI = require('wechat-api'); | |
var appid = 'xxx'; | |
var appsecret = 'xxxxx'; | |
var api = new WechatAPI(appid, appsecret); | |
var me4_id; | |
var openid_list; | |
api.getMaterials('image', 0, 200, function(err, result, res){ | |
if(err){console.log(err)} | |
else { | |
console.log(result); | |
var data = result.item[0]; | |
me4_id = data.media_id; | |
console.log(me4_id); | |
//test getFollowers & openid array & massSend | |
api.getFollowers(function(err, result){ | |
if(err){console.log(err)} | |
else{ | |
console.log(result); | |
var data = result.data; | |
openid_list = data.openid; | |
console.log(openid_list); | |
var opts = { | |
"image":{ | |
"media_id":me4_id | |
}, | |
"msgtype":"image" | |
} | |
api.massSend(opts, openid_list, function(err, result){ | |
if(err) {console.log(err)} | |
else | |
{ | |
console.log(result); | |
} | |
}) | |
api.massSendImage(me4_id, openid_list, function(err, result){ | |
if(err) {console.log(err)} | |
else | |
{ | |
console.log(result); | |
} | |
}) | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment