@chiefry/midway-wechat-api
v0.0.16
Published
Midway component for wechat official account api
Downloads
14
Readme
midway-wechat-api
Midway component for wechat official account api.
https://github.com/qdechochen/midway-wechat-api
need cacheManager and axios。
// configuration.ts
import * as wechatApi from '@chiefry/midway-wechat-api';
@Configuration({
imports: [
...
cacheManager,
axios,
wechatApi,
],
...
})// config.default.ts
export default {
...
wechat: {
appId: '',
appSecret: '',
token: '',
encodingAESKey: '',
cacheIndex: 'wechatApi', // 对应cacheManager,省略则为 default
presets: {
templates: {
hello: 'message template ID'
},
}
},
...
} as MidwayConfig;import { WechatApiService } from '@chiefry/midway-wechat-api';
export class A {
@Inject()
wechatApiService: WechatApiService;
async send() {
await this.wechatApiService.templateSend(
this.wechatApiService.presets.templates.hello,
'open id',
{
data: {
thing1: {
value: 'Hi there',
},
},
}
);
}
}