mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-07 22:22:28 +08:00
improve comment ,参考:https://github.com/huacnlee/autocorrect
This commit is contained in:
@@ -15,11 +15,11 @@ const (
|
||||
type (
|
||||
// SendRequestCommon 发送应用推送消息请求公共参数
|
||||
SendRequestCommon struct {
|
||||
// 群聊id
|
||||
// 群聊 id
|
||||
ChatID string `json:"chatid"`
|
||||
// 消息类型
|
||||
MsgType string `json:"msgtype"`
|
||||
// 表示是否是保密消息,0表示否,1表示是,默认0
|
||||
// 表示是否是保密消息,0 表示否,1 表示是,默认 0
|
||||
Safe int `json:"safe"`
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ type (
|
||||
}
|
||||
// TextField 文本消息参数
|
||||
TextField struct {
|
||||
// 消息内容,最长不超过2048个字节
|
||||
// 消息内容,最长不超过 2048 个字节
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ type (
|
||||
}
|
||||
// ImageField 图片消息参数
|
||||
ImageField struct {
|
||||
// 图片媒体文件id,可以调用上传临时素材接口获取
|
||||
// 图片媒体文件 id,可以调用上传临时素材接口获取
|
||||
MediaID string `json:"media_id"`
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ type (
|
||||
}
|
||||
// VoiceField 语音消息参数
|
||||
VoiceField struct {
|
||||
// 语音文件id,可以调用上传临时素材接口获取
|
||||
// 语音文件 id,可以调用上传临时素材接口获取
|
||||
MediaID string `json:"media_id"`
|
||||
}
|
||||
)
|
||||
@@ -65,7 +65,7 @@ type (
|
||||
// Send 发送应用消息
|
||||
// @desc 实现企业微信发送应用消息接口:https://developer.work.weixin.qq.com/document/path/90248
|
||||
func (r *Client) Send(apiName string, request interface{}) (*SendResponse, error) {
|
||||
// 获取accessToken
|
||||
// 获取 accessToken
|
||||
accessToken, err := r.GetAccessToken()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -75,7 +75,7 @@ func (r *Client) Send(apiName string, request interface{}) (*SendResponse, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 发起http请求
|
||||
// 发起 http 请求
|
||||
response, err := util.HTTPPost(fmt.Sprintf(sendURL, accessToken), string(jsonData))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -89,25 +89,25 @@ func (r *Client) Send(apiName string, request interface{}) (*SendResponse, error
|
||||
|
||||
// SendText 发送文本消息
|
||||
func (r *Client) SendText(request SendTextRequest) (*SendResponse, error) {
|
||||
// 发送文本消息MsgType参数固定为:text
|
||||
// 发送文本消息 MsgType 参数固定为:text
|
||||
request.MsgType = "text"
|
||||
return r.Send("MessageSendText", request)
|
||||
}
|
||||
|
||||
// SendImage 发送图片消息
|
||||
func (r *Client) SendImage(request SendImageRequest) (*SendResponse, error) {
|
||||
// 发送图片消息MsgType参数固定为:image
|
||||
// 发送图片消息 MsgType 参数固定为:image
|
||||
request.MsgType = "image"
|
||||
return r.Send("MessageSendImage", request)
|
||||
}
|
||||
|
||||
// SendVoice 发送语音消息
|
||||
func (r *Client) SendVoice(request SendVoiceRequest) (*SendResponse, error) {
|
||||
// 发送语音消息MsgType参数固定为:voice
|
||||
// 发送语音消息 MsgType 参数固定为:voice
|
||||
request.MsgType = "voice"
|
||||
return r.Send("MessageSendVoice", request)
|
||||
}
|
||||
|
||||
// 以上实现了部分常用消息推送:SendText 发送文本消息、SendImage 发送图片消息、SendVoice 发送语音消息,
|
||||
// 如需扩展其他消息类型,建议按照以上格式,扩展对应消息类型的参数即可
|
||||
// 也可以直接使用Send方法,按照企业微信消息推送的接口文档传对应消息类型的参数来使用
|
||||
// 也可以直接使用 Send 方法,按照企业微信消息推送的接口文档传对应消息类型的参数来使用
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Package appchat 应用发送消息到群聊会话,企业微信接口:https://developer.work.weixin.qq.com/document/path/90248
|
||||
// Package appchat 应用发送消息到群聊会话,企业微信接口:https://developer.work.weixin.qq.com/document/path/90248
|
||||
package appchat
|
||||
|
||||
import (
|
||||
|
||||
Reference in New Issue
Block a user