Documentation
¶
Index ¶
- Constants
- type API
- func (a *API) BatchDeleteUser(userIds []string) error
- func (a *API) CreateChat(chat *Chat) error
- func (a *API) CreateDepartment(department *Department) error
- func (a *API) CreateMenu(agentID int64, menu Menu) error
- func (a *API) CreateUser(user *User) error
- func (a *API) DeleteDepartment(id int64) error
- func (a *API) DeleteMenu(agentID int64) error
- func (a *API) DeleteUser(userID string) error
- func (a *API) DownloadMedia(mediaID string, writer io.Writer) (string, error)
- func (a *API) FetchToken() (token string, expiresIn int64, err error)
- func (a *API) GetJSSDKSignature(uri, timestamp, noncestr string) (string, error)
- func (a *API) GetMenu(agentID int64) (Menu, error)
- func (a *API) GetOAuth2AuthorizeURI(redirectURI, state string) string
- func (a *API) GetOAuth2User(agentID int64, code string) (OAuth2UserInfo, error)
- func (a *API) GetTaskResult(taskID string) (AsyncTaskResultInfo, error)
- func (a *API) GetUser(userID string) (*User, error)
- func (a *API) InviteUser(userID, inviteTips string) (inviteType int, err error)
- func (a *API) ListDepartment(id int64) ([]*Department, error)
- func (a *API) ListSimpleUser(departmentID int64, fetchChild *int, status *int) ([]*User, error)
- func (a *API) ListUser(departmentID int64, fetchChild *int, status *int) ([]*User, error)
- func (a *API) NewRecvMsgHandler() *recvMsgHandler
- func (a *API) PerformInviteUsersTask(task InviteTask) (string, error)
- func (a *API) PerformReplaceDepartmentTask(task UpdateContactTask) (string, error)
- func (a *API) PerformReplaceUsersTask(task UpdateContactTask) (string, error)
- func (a *API) PerformUpdateUsersTask(task UpdateContactTask) (string, error)
- func (a *API) Retriable(reqURL string, body []byte) (bool, string, error)
- func (a *API) SendMessage(message interface{}) error
- func (a *API) SendTextMessage(chatTextMessage *ChatTextMessage) error
- func (a *API) UpdateDepartment(department *Department) error
- func (a *API) UpdateUser(user *User) error
- func (a *API) UploadMedia(mediaType mediaType, filename string, reader io.Reader) (UploadedMedia, error)
- type Article
- type Articles
- type AsyncTaskCallback
- type AsyncTaskResultInfo
- type Chat
- type ChatReceiver
- type ChatText
- type ChatTextMessage
- type Department
- type FileMessage
- type ImageMessage
- type InviteTask
- type InviteUserTaskResult
- type JobResultInfo
- type Media
- type Menu
- type MenuButton
- type MessageType
- type MpArticle
- type MpArticles
- type MpNewsMessage
- type NewsMessage
- type OAuth2UserInfo
- type RecvBaseData
- type RecvBatchJobResultEvent
- type RecvEnterAgentEvent
- type RecvImageMessage
- type RecvLocationEvent
- type RecvLocationMessage
- type RecvLocationSelectEvent
- type RecvMenuEvent
- type RecvPicEvent
- type RecvScanCodeEvent
- type RecvSubscribeEvent
- type RecvTextMessage
- type RecvVideoMessage
- type RecvVoiceMessage
- type RespArticle
- type RespArticleItem
- type RespBaseData
- type RespImageMessage
- type RespMedia
- type RespNewsMessage
- type RespTextMessage
- type RespVideoMedia
- type RespVideoMessage
- type RespVoiceMessage
- type ScanCodeInfo
- type SendLocationInfo
- type SendPicItem
- type SendPicMD5Sum
- type SendPicsInfo
- type TextContent
- type TextMessage
- type UpdateContactTask
- type UpdateDepartmentTaskResult
- type UpdateUserTaskResult
- type UploadedMedia
- type User
- type UserAttribute
- type UserAttributes
- type VideoContent
- type VideoMessage
- type VoiceMessage
Constants ¶
const ( SyncUserTask = "sync_user" ReplaceUserTask = "replace_user" InviteUserTask = "invite_user" ReplaceDepartmentTask = "replace_party" )
异步任务操作类型
const ( ImageMedia mediaType = "image" VoiceMedia mediaType = "voice" VideoMedia mediaType = "video" FileMedia mediaType = "file" )
媒体文件类型
const ( MenuButtonTypeClick = "click" MenuButtonTypeView = "view" MenuButtonTypeScanCodePush = "scancode_push" MenuButtonTypeScanCodeWaitMsg = "scancode_waitmsg" MenuButtonTypePicSysPhoto = "pic_sysphoto" MenuButtonTypePicPhotoOrAlbum = "pic_photo_or_album" MenuButtonTypePicWeixin = "pic_weixin" MenuButtonTypeLocationSelect = "location_select" )
自定义菜单按钮类型
const ( SubscribeEvent = "subscribe" UnsubscribeEvent = "unsubscribe" LocationEvent = "LOCATION" MenuClickEvent = "CLICK" MenuViewEvent = "VIEW" ScanCodePushEvent = "scancode_push" ScanCodeWaitMsgEvent = "scancode_waitmsg" PicSysPhotoEvent = "pic_sysphoto" PicPhotoOrAlbumEvent = "pic_photo_or_album" PicWeiXinEvent = "pic_weixin" LocationSelectEvent = "location_select" EnterAgentEvent = "enter_agent" BatchJobResultEvent = "batch_job_result" )
接收事件类型
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
CorpID string
MsgCrypter crypter.MessageCrypter
Client *base.Client
Tokener *base.Tokener
// contains filtered or unexported fields
}
API 封装了企业号相关的接口操作
func (*API) BatchDeleteUser ¶
BatchDeleteUser 方法用于批量删除用户
func (*API) CreateDepartment ¶
func (a *API) CreateDepartment(department *Department) error
CreateDepartment 方法用于创建部门
func (*API) CreateMenu ¶
CreateMenu 方法用于创建某个应用的菜单
func (*API) DeleteDepartment ¶
DeleteDepartment 方法用于删除部门
func (*API) DownloadMedia ¶
DownloadMedia 方法用于从微信服务器获取媒体文件,文件流将写入 writer 中,并返回 filename 或者 error 信息
func (*API) FetchToken ¶
FetchToken 方法使用企业管理组的密钥向 API 服务器获取企业号的令牌信息
func (*API) GetJSSDKSignature ¶
GetJSSDKSignature 方法用于获取 JSSDK 的签名
func (*API) GetOAuth2AuthorizeURI ¶
GetOAuth2AuthorizeURI 方法用于构建 OAuth2 中企业获取 code 的 URL 地址
func (*API) GetOAuth2User ¶
func (a *API) GetOAuth2User(agentID int64, code string) (OAuth2UserInfo, error)
GetOAuth2User 方法用于获取 OAuth2 方式验证登录后的用户信息
func (*API) GetTaskResult ¶
func (a *API) GetTaskResult(taskID string) (AsyncTaskResultInfo, error)
GetTaskResult 方法用于获取异步任务的完成结果
func (*API) InviteUser ¶
InviteUser 方法用于邀请成员关注
func (*API) ListDepartment ¶
func (a *API) ListDepartment(id int64) ([]*Department, error)
ListDepartment 方法用于获取部门列表,获取根部门时 id 为 1
func (*API) ListSimpleUser ¶
ListSimpleUser 方法用于获取部门成员列表(成员仅有简单信息)
func (*API) NewRecvMsgHandler ¶
func (a *API) NewRecvMsgHandler() *recvMsgHandler
NewRecvMsgHandler 方法用于创建消息接收处理器的实例
func (*API) PerformInviteUsersTask ¶
func (a *API) PerformInviteUsersTask(task InviteTask) (string, error)
PerformInviteUsersTask 方法执行邀请成员关注的任务
func (*API) PerformReplaceDepartmentTask ¶
func (a *API) PerformReplaceDepartmentTask(task UpdateContactTask) (string, error)
PerformReplaceDepartmentTask 方法执行全量更新部门的任务
func (*API) PerformReplaceUsersTask ¶
func (a *API) PerformReplaceUsersTask(task UpdateContactTask) (string, error)
PerformReplaceUsersTask 方法执行全量更新成员的任务
func (*API) PerformUpdateUsersTask ¶
func (a *API) PerformUpdateUsersTask(task UpdateContactTask) (string, error)
PerformUpdateUsersTask 方法执行增量更新成员的任务
func (*API) SendMessage ¶
SendMessage 方法用于主动发送消息给企业成员
func (*API) SendTextMessage ¶
func (a *API) SendTextMessage(chatTextMessage *ChatTextMessage) error
func (*API) UpdateDepartment ¶
func (a *API) UpdateDepartment(department *Department) error
UpdateDepartment 方法用于更新部门信息
func (*API) UploadMedia ¶
func (a *API) UploadMedia(mediaType mediaType, filename string, reader io.Reader) (UploadedMedia, error)
UploadMedia 方法用于将媒体文件上传至微信服务器
type Article ¶
type Article struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
URL string `json:"url,omitempty"`
PicURL string `json:"picurl,omitempty"`
}
Article 为普通图文消息的文章内容
type AsyncTaskCallback ¶
type AsyncTaskCallback struct {
URL string `json:"url"`
Token string `json:"token"`
EncodingAESKey string `json:"encodingaeskey"`
}
AsyncTaskCallback 异步任务的回调信息
type AsyncTaskResultInfo ¶
type AsyncTaskResultInfo struct {
Status int `json:"status"`
Type string `json:"type"`
Total int `json:"total"`
Percentage float64 `json:"percentage"`
RemainTime float64 `json:"remaintime"`
Result interface{} `json:"result"`
}
AsyncTaskResultInfo 为异步任务完成结果信息
type ChatReceiver ¶
type ChatTextMessage ¶
type ChatTextMessage struct {
Receiver *ChatReceiver `json:"receiver"`
Sender string `json:"sender,omitempty"`
Msgtype string `json:"msgtype"`
Text *ChatText `json:"text"`
}
type Department ¶
type Department struct {
ID int64 `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Order int64 `json:"order,omitempty"`
ParentID int64 `json:"parentid,omitempty"`
}
Department 表示部门信息
type FileMessage ¶
type FileMessage struct {
ToUser string `json:"touser,omitempty"`
ToParty string `json:"toparty,omitempty"`
ToTag string `json:"totag,omitempty"`
MsgType MessageType `json:"msgtype"`
AgentID int64 `json:"agentid"`
File Media `json:"file"`
Safe int `json:"safe"`
}
FileMessage 为发送的文件类型消息
type ImageMessage ¶
type ImageMessage struct {
ToUser string `json:"touser,omitempty"`
ToParty string `json:"toparty,omitempty"`
ToTag string `json:"totag,omitempty"`
MsgType MessageType `json:"msgtype"`
AgentID int64 `json:"agentid"`
Image Media `json:"image"`
Safe int `json:"safe"`
}
ImageMessage 为发送的图片类型消息
type InviteTask ¶
type InviteTask struct {
ToUser string `json:"touser,omitempty"`
ToParty string `json:"toparty,omitempty"`
ToTag string `json:"totag,omitempty"`
InviteTips string `json:"invite_tips,omitempty"`
Callback AsyncTaskCallback `json:"callback"`
}
InviteTask 批量邀请成员关注企业号的异步任务信息
type InviteUserTaskResult ¶
type InviteUserTaskResult struct {
base.Error
UserID string `json:"userid"`
InviteType int `json:"invitetype"`
}
InviteUserTaskResult 邀请成员关注任务的执行结构信息
type JobResultInfo ¶
JobResultInfo 描述异步任务完成事件中任务完成情况信息
type MenuButton ¶
type MenuButton struct {
Type string `json:"type"`
Name string `json:"name"`
Key string `json:"key,omitempty"`
URL string `json:"url,omitempty"`
SubButtons []MenuButton `json:"sub_button,omitempty"`
}
MenuButton 中最多包含 5 个子菜单(二级菜单)
type MessageType ¶
type MessageType string
MessageType 消息类型定义
const ( TextMsg MessageType = "text" ImageMsg MessageType = "image" VoiceMsg MessageType = "voice" VideoMsg MessageType = "video" FileMsg MessageType = "file" NewsMsg MessageType = "news" MpNewsMsg MessageType = "mpnews" LocationMsg MessageType = "location" EventMsg MessageType = "event" )
各种消息类型值
type MpArticle ¶
type MpArticle struct {
Title string `json:"title"`
ThumbMediaID string `json:"thumb_media_id"`
Author string `json:"author,omitempty"`
ContentSourceURL string `json:"content_source_url,omitempty"`
Content string `json:"content"`
Digest string `json:"digest,omitempty"`
ShowCoverPic *int `json:"show_cover_pic,omitempty"`
}
MpArticle 为特殊图文消息的文章内容
type MpArticles ¶
type MpArticles struct {
Articles []MpArticle `json:"articles"`
}
MpArticles 为特殊图文消息的文章列表
type MpNewsMessage ¶
type MpNewsMessage struct {
ToUser string `json:"touser,omitempty"`
ToParty string `json:"toparty,omitempty"`
ToTag string `json:"totag,omitempty"`
MsgType MessageType `json:"msgtype"`
AgentID int64 `json:"agentid"`
MpNews MpArticles `json:"mpnews"`
Safe int `json:"safe"`
}
MpNewsMessage 为发送的特殊图文类型消息
type NewsMessage ¶
type NewsMessage struct {
ToUser string `json:"touser,omitempty"`
ToParty string `json:"toparty,omitempty"`
ToTag string `json:"totag,omitempty"`
MsgType MessageType `json:"msgtype"`
AgentID int64 `json:"agentid"`
News Articles `json:"news"`
}
NewsMessage 为发送的普通图文类型消息
type OAuth2UserInfo ¶
OAuth2UserInfo 为用户 OAuth2 验证登录后的简单信息
type RecvBaseData ¶
type RecvBaseData struct {
ToUserName string
FromUserName string
CreateTime int
MsgType MessageType
AgentID int64
}
RecvBaseData 描述接收到的各类消息或事件的公共结构
type RecvBatchJobResultEvent ¶
type RecvBatchJobResultEvent struct {
RecvBaseData
Event string
BatchJob JobResultInfo
}
RecvBatchJobResultEvent 描述异步任务完成事件的结构
type RecvEnterAgentEvent ¶
type RecvEnterAgentEvent struct {
RecvBaseData
Event string
EventKey string
}
RecvEnterAgentEvent 描述成员进入应用事件的结构
type RecvImageMessage ¶
type RecvImageMessage struct {
RecvBaseData
MsgID uint64 `xml:"MsgId"`
PicURL string `xml:"PicUrl"`
MediaID string `xml:"MediaId"`
}
RecvImageMessage 描述接收到的图片类型消息结构
type RecvLocationEvent ¶
type RecvLocationEvent struct {
RecvBaseData
Event string
Latitude float64
Longitude float64
Precision float64
}
RecvLocationEvent 描述上报地理位置事件的结构
type RecvLocationMessage ¶
type RecvLocationMessage struct {
RecvBaseData
MsgID uint64 `xml:"MsgId"`
LocationX float64 `xml:"Location_X"`
LocationY float64 `xml:"Location_Y"`
Scale int
Label string
}
RecvLocationMessage 描述接收到的地理位置类型消息结构
type RecvLocationSelectEvent ¶
type RecvLocationSelectEvent struct {
RecvBaseData
Event string
EventKey string
SendLocationInfo SendLocationInfo
}
RecvLocationSelectEvent 描述弹出地理位置选择器事件的结构
type RecvMenuEvent ¶
type RecvMenuEvent struct {
RecvBaseData
Event string
EventKey string
}
RecvMenuEvent 描述菜单事件的结构
type RecvPicEvent ¶
type RecvPicEvent struct {
RecvBaseData
Event string
EventKey string
SendPicsInfo SendPicsInfo
}
RecvPicEvent 描述发图事件的结构
type RecvScanCodeEvent ¶
type RecvScanCodeEvent struct {
RecvBaseData
Event string
EventKey string
ScanCodeInfo ScanCodeInfo
}
RecvScanCodeEvent 描述扫码推/扫码推事件且弹出“消息接收中”提示框类型事件的结构
type RecvSubscribeEvent ¶
type RecvSubscribeEvent struct {
RecvBaseData
Event string
}
RecvSubscribeEvent 描述成员关注/取消关注事件的结构
type RecvTextMessage ¶
type RecvTextMessage struct {
RecvBaseData
MsgID uint64 `xml:"MsgId"`
Content string
}
RecvTextMessage 描述接收到的文本类型消息结构
type RecvVideoMessage ¶
type RecvVideoMessage struct {
RecvBaseData
MsgID uint64 `xml:"MsgId"`
MediaID string `xml:"MediaId"`
ThumbMediaID string `xml:"ThumbMediaId"`
}
RecvVideoMessage 描述接收到的视频类型消息结构
type RecvVoiceMessage ¶
type RecvVoiceMessage struct {
RecvBaseData
MsgID uint64 `xml:"MsgId"`
MediaID string `xml:"MediaId"`
Format string
}
RecvVoiceMessage 描述接收到的语音类型消息结构
type RespArticle ¶
type RespArticle struct {
Title base.CDATAText
Description base.CDATAText
PicURL base.CDATAText `xml:"PicUrl"`
URL base.CDATAText `xml:"Url"`
}
RespArticle 描述被动响应的图文消息结构
type RespArticleItem ¶
type RespArticleItem struct {
Item RespArticle `xml:"item"`
}
RespArticleItem 描述被动响应的图文消息结构的包裹
type RespBaseData ¶
type RespBaseData struct {
XMLName xml.Name `xml:"xml"`
ToUserName base.CDATAText
FromUserName base.CDATAText
CreateTime int
MsgType base.CDATAText
}
RespBaseData 描述被动响应消息的公共结构
type RespImageMessage ¶
type RespImageMessage struct {
RespBaseData
Image RespMedia
}
RespImageMessage 描述被动相应的图片消息结构
type RespNewsMessage ¶
type RespNewsMessage struct {
RespBaseData
ArticleCount int
Articles []RespArticleItem
}
RespNewsMessage 描述被动相应的图文消息结构
type RespTextMessage ¶
type RespTextMessage struct {
RespBaseData
Content base.CDATAText
}
RespTextMessage 描述被动响应的文本消息的结构
type RespVideoMedia ¶
type RespVideoMedia struct {
MediaID base.CDATAText `xml:"MediaId"`
Title base.CDATAText
Description base.CDATAText
}
RespVideoMedia 描述被动相应的视频媒体内容结构
type RespVideoMessage ¶
type RespVideoMessage struct {
RespBaseData
Video RespVideoMedia
}
RespVideoMessage 描述被动相应的语音消息结构
type RespVoiceMessage ¶
type RespVoiceMessage struct {
RespBaseData
Voice RespMedia
}
RespVoiceMessage 描述被动相应的语音消息结构
type ScanCodeInfo ¶
ScanCodeInfo 描述扫码事件的相关内容结构
type SendLocationInfo ¶
type SendLocationInfo struct {
LocationX float64 `xml:"Location_X"`
LocationY float64 `xml:"Location_Y"`
Scale int
Label string
PoiName string `xml:"Poiname"`
}
SendLocationInfo 描述弹出地理位置选择器事件中地理位置信息结构
type SendPicItem ¶
type SendPicItem struct {
Item SendPicMD5Sum `xml:"item"`
}
SendPicItem 描述发图事件中单个图片信息结构
type SendPicMD5Sum ¶
type SendPicMD5Sum struct {
PicMd5Sum string
}
SendPicMD5Sum 描述发图事件中单个图片的 MD5 信息
type SendPicsInfo ¶
type SendPicsInfo struct {
Count int64
PicList []SendPicItem
}
SendPicsInfo 描述发图事件的图片信息结构
type TextContent ¶
type TextContent struct {
Content string `json:"content"`
}
TextContent 为文本类型消息的文本内容
type TextMessage ¶
type TextMessage struct {
ToUser string `json:"touser,omitempty"`
ToParty string `json:"toparty,omitempty"`
ToTag string `json:"totag,omitempty"`
MsgType MessageType `json:"msgtype"`
AgentID int64 `json:"agentid"`
Text TextContent `json:"text"`
Safe int `json:"safe"`
}
TextMessage 为发送的文本类型消息
type UpdateContactTask ¶
type UpdateContactTask struct {
MediaID string `json:"media_id"`
Callback AsyncTaskCallback `json:"callback"`
}
UpdateContactTask 增量更新企业成员、全量更新成员或部门的异步任务信息
type UpdateDepartmentTaskResult ¶
type UpdateDepartmentTaskResult struct {
base.Error
Action int `json:"action"`
DepartmentID int64 `json:"partyid"`
}
UpdateDepartmentTaskResult 全量更新部门任务的执行结果信息
type UpdateUserTaskResult ¶
type UpdateUserTaskResult struct {
base.Error
Action int `json:"action"`
UserID string `json:"userid"`
}
UpdateUserTaskResult 增量、全量更新成员任务的执行结果信息
type UploadedMedia ¶
type UploadedMedia struct {
Type string `json:"type"`
MediaID string `json:"media_id"`
CreatedAt int64 `json:"created_at"`
}
UploadedMedia 上传成功的媒体文件信息
type User ¶
type User struct {
UserID string `json:"userid"`
Name string `json:"name,omitempty"`
DepartmentIds []int64 `json:"department,omitempty"`
Position string `json:"position,omitempty"`
Mobile string `json:"mobile,omitempty"`
Email string `json:"email,omitempty"`
WeixinID string `json:"weixinid,omitempty"`
Enable *int `json:"enable,omitempty"`
Avatar string `json:"avatar,omitempty"`
Status *int `json:"status,omitempty"`
ExtAttr UserAttributes `json:"extattr,omitempty"`
}
User struct 为企业用户信息
type UserAttribute ¶
UserAttribute struct 为用户扩展信息
type UserAttributes ¶
type UserAttributes struct {
Attrs []*UserAttribute `json:"attrs,omitempty"`
}
UserAttributes struct 为用户扩展信息列表
type VideoContent ¶
type VideoContent struct {
ID string `json:"media_id"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
}
VideoContent 为视频类型消息的内容
type VideoMessage ¶
type VideoMessage struct {
ToUser string `json:"touser,omitempty"`
ToParty string `json:"toparty,omitempty"`
ToTag string `json:"totag,omitempty"`
MsgType MessageType `json:"msgtype"`
AgentID int64 `json:"agentid"`
Video VideoContent `json:"video"`
Safe int `json:"safe"`
}
VideoMessage 为发送的视频类型消息
type VoiceMessage ¶
type VoiceMessage struct {
ToUser string `json:"touser,omitempty"`
ToParty string `json:"toparty,omitempty"`
ToTag string `json:"totag,omitempty"`
MsgType MessageType `json:"msgtype"`
AgentID int64 `json:"agentid"`
Voice Media `json:"voice"`
Safe int `json:"safe"`
}
VoiceMessage 为发送的声音类型消息