123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package notice
- import (
- "github.com/fastwego/offiaccount"
- "github.com/fastwego/offiaccount/apis/account"
- "github.com/fastwego/offiaccount/apis/message/template"
- "kpt.notice/pkg/log"
- )
- type wxMessage struct {
- MsgType string `json:"msgtype"`
- Content string `json:"content"`
- }
- var ServerAcc *offiaccount.OffiAccount = offiaccount.New(offiaccount.Config{
- Appid: "wxe1cc563ba393dd1a",
- Secret: "25e56243da9581eab6f4d67a12ef4658",
- Token: "123",
- EncodingAESKey: "6yYJ4sS5y1hJgvIXEqavV2rmCutyXkywndxUQFgX54f",
- })
- func CreateQRCode(sceneID string) []byte {
- // time limit in 3 days
- json := `{
- "action_name": "QR_SCENE",
- "expire_seconds":259200,
- "action_info": {
- "scene": {
- "scene_id":` + sceneID + `
- }
- }`
- resp, err := account.CreateQRCode(ServerAcc, []byte(json))
- if err != nil {
- log.Error(err)
- return nil
- }
- return resp
- }
- /*
- send tmp message to wx
- */
- func MsgTemplate(msg []byte) ([]byte, error) {
- return template.Send(ServerAcc, msg)
- }
- // func OfficeInit() {
- // if ServerAcc == nil {
- // ServerAcc = offiaccount.New(offiaccount.Config{
- // Appid: "wxe1cc563ba393dd1a",
- // Secret: "25e56243da9581eab6f4d67a12ef4658",
- // Token: "123",
- // EncodingAESKey: "6yYJ4sS5y1hJgvIXEqavV2rmCutyXkywndxUQFgX54f",
- // })
- // }
- // }
|