var getMsg = function (_token,content) {
return new Promise(function (resolve, reject) {
var postData = {
content: content
};
postData = JSON.stringify(postData)
console.log(‘after’)
console.log(postData)
var options = {
hostname: ‘api.weixin.qq.com’,
path: ‘/wxa/msg_sec_check?access_token=’ + _token,
port:443,
method: ‘POST’,
headers:{
‘Referer’: ‘https://k3fcz9gw.qcloud.la/weapp/minganci/’,
‘Content-Type’: ‘application/json’,
‘Content-Length’: postData.length,
}
};
var msg = ‘’;
const reqB = https.request(options, (res) => {
console.log('STATUS: ’ + res.statusCode);
console.log('HEADERS: ’ + JSON.stringify(res.headers));
res.on(‘data’, function (data) {
console.log(‘data’)
msg += data;
});
res.on(‘end’, function () {
console.log(‘end’)
resolve(msg)
});
});
reqB.write(postData);
reqB.on(‘error’, function (e){
console.log(‘error’)
msg = e;
resolve(msg)
});
reqB.end();
})
}