wechat

package
v1.10.8 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

README

如何使用企业微信号来接收通知

  • 注册企业微信
  • 获取corpid
    每个企业都拥有唯一的corpid,获取此信息可在管理后台我的企业->企业信息->企业ID(需要有管理员权限)
  • 创建应用
    点击应用管理->自建->创建应用,填写应用名称,添加成员,然后点击创建应用,然后点击进入新创建的应用,将AgentIdSecret两个参数记录下来
  • 在微信中接收通知
    为了在微信中可以直接接收到消息,需要微信扫码关注微工作台,点击 我的企业->微工作台->邀请关注,使用微信关注即可接收到通知

Example

var (
   corpid = "wwb..."
   agentID = 1000002
   secret = "NgYcbPHa6DhR..."
)
func Send() {
	client := NewWeChat(corpid, agentID, secret)
	err := client.Send([]string{"..."}, "测试标题", "测试消息的文本")
	if err != nil {
		t.Error(err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MsgTypeText     = "text"
	MsgTypeTextCard = "textcard"
	MsgTypeMarkdown = "markdown"
)

Functions

This section is empty.

Types

type Client added in v1.10.6

type Client struct {
	CropID      string
	AgentID     int
	AgentSecret string
	Token       accessToken
	TextCard    map[string]interface{} `json:"textcard"`
}

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

func NewWeChat

func NewWeChat(cropID string, agentID int, agentSecret string) *Client

NewWeChat init wechat notidy

func (*Client) Send added in v1.10.6

func (c *Client) Send(tos, toParty, toTag []string, title, content string, msgTextCard map[string]interface{}) error

Send format send msg to Message

func (*Client) SetMsgType added in v1.10.6

func (c *Client) SetMsgType(msgType string)

type Content

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

Content 文本消息内容

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"`
	Markdown Content                `json:"markdown"`
	TextCard map[string]interface{} `json:"textcard"`
}

Message 消息主体参数

type Result

type Result struct {
	InvalidUser  string `json:"invaliduser"`
	InvalidParty string `json:"infvalidparty"`
	InvalidTag   string `json:"invalidtag"`
	// contains filtered or unexported fields
}

Result 发送消息返回结果

Jump to

Keyboard shortcuts

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