1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-08 14:42:26 +08:00

添加微信客服SDK (#436)

* 添加微信客服SDK

* polish:优化签名函数

* polish:优化注释内容

* polish:复用已有的Token以及CommonError,移除无用的输出

* polish:复用已有的消息加解密

* fix:修复错误信息被覆盖的问题

* polish:go fmt 文件
This commit is contained in:
Afeyer
2021-08-17 10:19:01 +08:00
committed by GitHub
parent fc1fc7e84e
commit 8ceabc2d0b
17 changed files with 1299 additions and 1 deletions

127
work/kf/sendmsg/message.go Normal file
View File

@@ -0,0 +1,127 @@
package sendmsg
// Message 发送消息
type Message struct {
ToUser string `json:"touser"` // 指定接收消息的客户UserID
OpenKFID string `json:"open_kfid"` // 指定发送消息的客服帐号ID
MsgID string `json:"msgid"` // 指定消息ID
}
// Text 发送文本消息
type Text struct {
Message
MsgType string `json:"msgtype"` // 消息类型此时固定为text
Text struct {
Content string `json:"content"` // 消息内容最长不超过2048个字节
} `json:"text"` // 文本消息
}
// Image 发送图片消息
type Image struct {
Message
MsgType string `json:"msgtype"` // 消息类型此时固定为image
Image struct {
MediaID string `json:"media_id"` // 图片文件id可以调用上传临时素材接口获取
} `json:"image"` // 图片消息
}
// Voice 发送语音消息
type Voice struct {
Message
MsgType string `json:"msgtype"` // 消息类型此时固定为voice
Voice struct {
MediaID string `json:"media_id"` // 语音文件id可以调用上传临时素材接口获取
} `json:"voice"` // 语音消息
}
// Video 发送视频消息
type Video struct {
Message
MsgType string `json:"msgtype"` // 消息类型此时固定为video
Video struct {
MediaID string `json:"media_id"` // 视频文件id可以调用上传临时素材接口获取
} `json:"video"` // 视频消息
}
// File 发送文件消息
type File struct {
Message
MsgType string `json:"msgtype"` // 消息类型此时固定为file
File struct {
MediaID string `json:"media_id"` // 文件id可以调用上传临时素材接口获取
} `json:"file"` // 文件消息
}
// Link 图文链接消息
type Link struct {
Message
MsgType string `json:"msgtype"` // 消息类型此时固定为link
Link struct {
Title string `json:"title"` // 标题不超过128个字节超过会自动截断
Desc string `json:"desc"` // 描述不超过512个字节超过会自动截断
URL string `json:"url"` // 点击后跳转的链接。 最长2048字节请确保包含了协议头(http/https)
ThumbMediaID string `json:"thumb_media_id"` // 缩略图的media_id, 可以通过素材管理接口获得。此处thumb_media_id即上传接口返回的media_id
} `json:"link"` // 链接消息
}
// MiniProgram 小程序消息
type MiniProgram struct {
Message
MsgType string `json:"msgtype"` // 消息类型此时固定为miniprogram
MiniProgram struct {
AppID string `json:"appid"` // 小程序appid必须是关联到企业的小程序应用
Title string `json:"title"` // 小程序消息标题最多64个字节超过会自动截断
ThumbMediaID string `json:"thumb_media_id"` // 小程序消息封面的mediaid封面图建议尺寸为520*416
PagePath string `json:"pagepath"` // 点击消息卡片后进入的小程序页面路径
} `json:"miniprogram"` // 小程序消息
}
// Menu 发送菜单消息
type Menu struct {
Message
MsgType string `json:"msgtype"` // 消息类型此时固定为msgmenu
MsgMenu struct {
HeadContent string `json:"head_content"` // 消息内容不多于1024字节
List []interface{} `json:"list"` // 菜单项配置
} `json:"msgmenu"`
}
// MenuClick 回复菜单
type MenuClick struct {
Type string `json:"type"` // 菜单类型: click 回复菜单
Click struct {
ID string `json:"id"` // 菜单ID, 不少于1字节, 不多于64字节
Content string `json:"content"` // 菜单显示内容, 不少于1字节, 不多于128字节
} `json:"click"`
}
// MenuView 超链接菜单
type MenuView struct {
Type string `json:"type"` // 菜单类型: view 超链接菜单
View struct {
URL string `json:"url"` // 点击后跳转的链接, 不少于1字节, 不多于2048字节
Content string `json:"content"` // 菜单显示内容, 不少于1字节, 不多于1024字节
} `json:"view"`
}
// MenuMiniProgram 小程序菜单
type MenuMiniProgram struct {
Type string `json:"type"` // 菜单类型: miniprogram 小程序菜单
MiniProgram struct {
AppID string `json:"appid"` // 小程序appid, 不少于1字节, 不多于32字节
PagePath string `json:"pagepath"` // 点击后进入的小程序页面, 不少于1字节, 不多于1024字节
Content string `json:"content"` // 菜单显示内容, 不少于1字节, 不多于1024字节
} `json:"miniprogram"`
}
// Location 地理位置消息
type Location struct {
Message
MsgType string `json:"msgtype"` // 消息类型此时固定为location
Location struct {
Latitude float32 `json:"latitude"` // 纬度, 浮点数范围为90 ~ -90
Longitude float32 `json:"longitude"` // 经度, 浮点数范围为180 ~ -180
Name string `json:"name"` // 位置名
Address string `json:"address"` // 地址详情说明
} `json:"location"`
}

View File

@@ -0,0 +1 @@
package sendmsg