0.0.16 • Published 12 months ago

@chiefry/midway-wechat-api v0.0.16

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

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',
          },
        },
      }
    );
  }
}
0.0.16

12 months ago

0.0.15

12 months ago

0.0.14

12 months ago

0.0.13

12 months ago

0.0.12

12 months ago

0.0.11

12 months ago

0.0.10

12 months ago