12345678910111213141516171819202122232425262728293031323334353637 |
- package utils
-
- import (
- "github.com/astaxie/beego"
- "github.com/zjxpcyc/wechat/wx"
- )
-
- var client *wx.Client
-
- // WxClientSingleton 初始化
- func WxClientSingleton(cert map[string]string) {
- client = wx.NewClient(cert)
- }
-
- // WxClient 微信实例
- func WxClient() *wx.Client {
- return client
- }
-
- // 初始化微信
- func InitWechat() {
- appRoot := GetAppRoot()
-
- wechatConf, _ := GetConfiger(appRoot + "/conf/wechat.conf")
- if wechatConf == nil {
- return
- }
- cert := map[string]string{
- "appid": wechatConf.String("appid"),
- "secret": wechatConf.String("secret"),
- "token": wechatConf.String("token"),
- "aeskey": "",
- "wxid": wechatConf.String("wxid"),
- }
- beego.Error(cert)
- WxClientSingleton(cert)
- }
|