wechat

package
v4.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(wechat WechatSection)

func RobotSend

func RobotSend(msg Message) error

RobotSend robot发送信息

Types

type AccessToken

type AccessToken struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
	Err
	ExpiresInTime time.Time
}

AccessToken 微信企业号请求Token

type Client

type Client struct {
	CorpID      string
	AgentID     int
	AgentSecret string
	Token       AccessToken
}

Client 微信企业号应用配置信息

func New

func New(corpID string, agentID int, agentSecret string) *Client

New 实例化微信企业号应用

func (*Client) GetAccessToken

func (c *Client) GetAccessToken() error

GetAccessToken 获取会话token

func (*Client) Send

func (c *Client) Send(msg Message) error

Send 发送信息

type Content

type Content struct {
	Content string `json:"content"`
}

Content 文本消息内容

type Err

type Err struct {
	ErrCode int    `json:"errcode"`
	ErrMsg  string `json:"errmsg"`
}

Err 微信返回错误

type Message

type Message struct {
	ToUser  string  `json:"touser"`
	ToParty string  `json:"toparty"`
	ToTag   string  `json:"totag"`
	MsgType string  `json:"msgtype"`
	AgentID int     `json:"agentid"`
	Text    Content `json:"text"`
}

Message 消息主体参数

type Result

type Result struct {
	Err
	InvalidUser  string `json:"invaliduser"`
	InvalidParty string `json:"infvalidparty"`
	InvalidTag   string `json:"invalidtag"`
}

Result 发送消息返回结果

type WechatSection

type WechatSection struct {
	CorpID  string `yaml:"corp_id"`
	AgentID int    `yaml:"agent_id"`
	Secret  string `yaml:"secret"`
}
var WeChat WechatSection

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL