1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- /**
- * 简易互联网医院 企业微信消息推送 SDK,提供互联网医院 企业微信消息推送接口调用。
- */
- 'use strict';
- let http = require('http');
- var reqq = require('request');
- let querystring = require('querystring');
- let configFile = require('../include/commons').CONFIG_FILE;
- let config = require('../resources/config/' + configFile);
- let log = require('./log.js');
- class HlwyyAssistantSDK {
- constructor(){}
- static request(enterpriseId,title,doctor,description,url, params,handler){
- log.info("1:"+enterpriseId)
- log.info("2:"+title)
- log.info("3:"+doctor)
- log.info("4:"+description)
- log.info("5:"+url)
- // let userAgent = {
- // admin_token: adminToken,
- // token: token,
- // uid: userId,
- // imei: imei
- // };
- // var postData=querystring.stringify(params);
- //
- // let options = {
- // hostname: config.hlwyyDAServerConfig.host,
- // port: config.hlwyyDAServerConfig.port,
- // path: config.hlwyyDAServerConfig.model+config.hlwyyDAServerConfig.enpoint+"?"+params,
- // method: 'POST',
- // headers: {
- // // 'userAgent': JSON.stringify(userAgent),
- // 'Content-Type': 'application/x-www-form-urlencoded;text/html;charset=utf-8'
- // // 'Content-Type': 'application/json;charset=UTF-8'
- // }
- // ,
- // body:JSON.stringify({enterpriseId:enterpriseId,
- // title:title,
- // doctor:doctor,
- // description:description,
- // url:url})
- // };
- //
- // let requestData= JSON.stringify({enterpriseId:enterpriseId,
- // title:title,
- // doctor:doctor,
- // description:description,
- // url:url})
- reqq({
- url: "http://"+config.hlwyyDAServerConfig.host+":"+config.hlwyyDAServerConfig.port+config.hlwyyDAServerConfig.model+config.hlwyyDAServerConfig.enpoint+"?"+params,
- method: "POST",
- json: true,
- headers: {
- "content-type": "application/json",
- },
- body: params
- }, function(error, response, body) {
- if (!error && response.statusCode == 200) {
- log.info('企业微信消息推送->请求成功:', body);
- // console.log(body) // 请求成功的处理逻辑
- }else{
- log.error('企业微信消息推送->请求失败: ', error.message);
- }
- });
- //
- //
- // let req = http.request(options, function (res) {
- // res.setEncoding('utf-8');
- // res.on('data', function (chunk) {
- // log.info('企业微信消息推送->请求成功:', chunk);
- //
- // handler(null, chunk);
- // });
- // });
- //
- // req.on('error', function (err) {
- // log.error('企业微信消息推送->请求失败: ', err.message);
- //
- // handler(err, null);
- // });
- // req.write(postData);
- // req.end();
- }
- }
- module.exports = HlwyyAssistantSDK;
|