mp

package
v0.0.0-...-78ab787 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2019 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpCreateSession      = 1000
	OpAcceptSession      = 1001
	OpInitiateSession    = 1002
	OpSwitchSession      = 1003
	OpCloseSession       = 1004
	OpRobSession         = 1005
	OpBackendRecvMessage = 2001
	OpAgentSendMessage   = 2002
	OpAgentRecvMessage   = 2003
)
View Source
const (
	OK                 = 0
	InvalidCredential  = 40001
	AccessTokenExpired = 42001
)
View Source
const (
	MessageText  = "text"
	MessageImage = "image"
	MessageVoice = "voice"
	MessageVideo = "video"
	MessageMusic = "music"
	MessageNews  = "news"
	MessageEvent = "event"
)

Received message types

View Source
const (
	EventSubscribe                   = "subscribe"
	EventUnsubscribe                 = "unsubscribe"
	EventScan                        = "SCAN"
	EventLocation                    = "LOCATION"
	EventMenuClick                   = "CLICK"
	EventMenuView                    = "VIEW"
	EventCreateAgentSession          = "kf_create_session"
	EventCloseAgentSession           = "kf_close_session"
	EventSwitchAgentSession          = "kf_switch_session"
	EventQualificationVerifySuccess  = "qualification_verify_success"
	EventQualificationVerifyFail     = "qualification_verify_fail"
	EventNamingVerifySuccess         = "naming_verify_success"
	EventNamingVerifyFail            = "naming_verify_fail"
	EventAnnualRenew                 = "annual_renew"
	EventVerifyExpired               = "verify_expired"
	EventCardPassCheck               = "card_pass_check"
	EventNotCardPassCheck            = "card_not_pass_check"
	EventUserGetCard                 = "user_get_card"
	EventUserDelCard                 = "user_del_card"
	EventUserConsumeCard             = "user_consume_card"
	EventUserPayFromPayCell          = "user_pay_from_pay_cell"
	EventUserViewCard                = "user_view_card"
	EventUserEnterSessionFromCard    = "user_enter_session_from_card"
	EventUpdateMemberCard            = "update_member_card"
	EventCardSkuRemind               = "card_sku_remind"
	EventCardPayOrder                = "card_pay_order"
	EventUserScanProduct             = "user_scan_product"
	EventUserScanProductEnterSession = "user_scan_product_enter_session"
	EventUserScanProductAsync        = "user_scan_product_async"
	EventUserScanProductVerifyAction = "user_scan_product_verify_action"
	EventShakeAroundUserShake        = "ShakearoundUserShake"
)

Event types for MessageEvent

View Source
const (
	MediaImage = "image"
	MediaVoice = "voice"
	MediaVideo = "video"
	MediaThumb = "thumb"
	MediaNews  = "news"
)
View Source
const (
	// 下面6个类型(包括view类型)的按钮是在公众平台官网发布的菜单按钮类型
	ButtonTypeText  = "text"
	ButtonTypeImage = "img"
	ButtonTypePhoto = "photo"
	ButtonTypeVideo = "video"
	ButtonTypeVoice = "voice"

	ButtonTypeView  = "view"  // 跳转URL
	ButtonTypeClick = "click" // 点击推事件

	ButtonTypeMiniprogram = "miniprogram" // 小程序

	// 下面的按钮类型仅支持微信 iPhone5.4.1 以上版本, 和 Android5.4 以上版本的微信用户,
	// 旧版本微信用户点击后将没有回应, 开发者也不能正常接收到事件推送
	ButtonTypeScanCodePush    = "scancode_push"      // 扫码推事件
	ButtonTypeScanCodeWaitMsg = "scancode_waitmsg"   // 扫码带提示
	ButtonTypePicSysPhoto     = "pic_sysphoto"       // 系统拍照发图
	ButtonTypePicPhotoOrAlbum = "pic_photo_or_album" // 拍照或者相册发图
	ButtonTypePicWeixin       = "pic_weixin"         // 微信相册发图
	ButtonTypeLocationSelect  = "location_select"    // 发送位置

	// 下面的按钮类型专门给第三方平台旗下未微信认证(具体而言, 是资质认证未通过)的订阅号准备的事件类型,
	// 它们是没有事件推送的, 能力相对受限, 其他类型的公众号不必使用
	ButtonTypeMediaId     = "media_id"     // 下发消息
	ButtonTypeViewLimited = "view_limited" // 跳转图文消息URL
)
View Source
const (
	MsgText    = "text"
	MsgImage   = "image"
	MsgVoice   = "voice"
	MsgMPVideo = "mpvideo"
	MsgMPNews  = "mpnews"
	MsgCard    = "wxcard"
	MsgVideo   = "video" // corp
	MsgFile    = "file"  // corp
	MsgNews    = "news"  // corp
)
View Source
const (
	SendAll = iota
	SendByUsers
	SendForPreview

	SendByParties // corp
	SendByTags    // corp
)
View Source
const (
	LangZhCN = "zh_CN"
	LangZhTW = "zh_TW"
	LangEN   = "en"
)
View Source
const BLOCK_SIZE = 32

Variables

View Source
var MaxMemoryForFile = 10 * 1024 * 1024

Functions

This section is empty.

Types

type AESKey

type AESKey struct {
	// contains filtered or unexported fields
}

type Agent

type Agent struct {
	Id           int64  `json:"kf_id"`
	Account      string `json:"kf_account"` // identifier@account
	Nickname     string `json:"kf_nick"`
	HeadImageURL string `json:"kf_headimgurl"`
}

Customer Service Agent

type AgentSession

type AgentSession struct {
	OpenId     string `json:"openid"`
	Account    string `json:"kf_account"` // accepted agent account; empty if not accepted
	CreateTime int64  `json:"createtime"`
}

type AgentSessionChange

type AgentSessionChange struct {
	Account     string `xml:"KfAccount"     json:"KfAccount"`
	FromAccount string `xml:"FromKfAccount" json:"FromKfAccount"`
	ToAccount   string `xml:"ToKfAccount"   json:"ToKfAccount"`
}

type Article

type Article struct {
	ThumbId          string `json:"thumb_media_id"` // permant media id of cover picture
	Title            string `json:"title"`
	Author           string `json:"author,omitempty"`
	Digest           string `json:"digest,omitempty"`             // only valid for single-article news
	Content          string `json:"content"`                      // content, supporting HTML, no JS, less than 20000 chars or 1MB
	ContentSourceURL string `json:"content_source_url,omitempty"` // URL of "Read the original content"
	ShowCoverPic     int    `json:"show_cover_pic"`               // whether show cover picture
	ThumbURL         string `json:"thumb_url"`                    // cover picture URL, only valid for GetNews
	URL              string `json:"url"`                          // content URL, only valid for GetNews
}

Article of words and images

type Beacon

type Beacon struct {
	UUID     string  `xml:"Uuid"     json:"Uuid"`
	Major    int     `xml:"Major"    json:"Major"`
	Minor    int     `xml:"Minor"    json:"Minor"`
	Distance float64 `xml:"Distance" json:"Distance"`
}

type Button

type Button struct {
	Type       string    `json:"type,omitempty"`
	SubButtons []*Button `json:"sub_button,omitempty"`
	Name       string    `json:"name,omitempty"`     // 菜单标题,不超过16个字节,子菜单不超过60个字节
	Key        string    `json:"key,omitempty"`      // 菜单KEY值,用于消息接口推送,不超过128字节
	URL        string    `json:"url,omitempty"`      // 网页链接,用户点击菜单可打开链接,不超过1024字节
	MediaID    string    `json:"media_id,omitempty"` // 调用新增永久素材接口返回的合法media_id
	AppID      string    `json:"appid,omitempty"`    // 小程序AppID(仅认证公众号可配置)
	PagePath   string    `json:"pagepath"`           // 小程序的页面路径
}

func NewButtonForClick

func NewButtonForClick(name, key string) *Button

func NewButtonForLocationSelect

func NewButtonForLocationSelect(name, key string) *Button

func NewButtonForMediaId

func NewButtonForMediaId(name, mediaID string) *Button

func NewButtonForMiniprogram

func NewButtonForMiniprogram(name, url, appID, pagePath string) *Button

func NewButtonForPicPhotoOrAlbum

func NewButtonForPicPhotoOrAlbum(name, key string) *Button

func NewButtonForPicSysPhoto

func NewButtonForPicSysPhoto(name, key string) *Button

func NewButtonForPicWeixin

func NewButtonForPicWeixin(name, key string) *Button

func NewButtonForScanCodePush

func NewButtonForScanCodePush(name, key string) *Button

func NewButtonForScanCodeWaitMsg

func NewButtonForScanCodeWaitMsg(name, key string) *Button

func NewButtonForView

func NewButtonForView(name, url string) *Button

func NewButtonForViewLimited

func NewButtonForViewLimited(name, mediaID string) *Button

func NewButtonWithSubButtons

func NewButtonWithSubButtons(name string, subButtons []*Button) *Button

type Card

type Card struct {
	Id  string `json:"card_id"`
	Ext string `json:"card_ext,omitempty"`
}

type Client

type Client struct {
	*TokenAccessor
	*http.Client

	AgentID int64 // corp app ID
}

func NewClient

func NewClient(appID, appSecret string, needsTicket bool) *Client

func NewCorpClient

func NewCorpClient(corpID, secret string, agentID int64) *Client

func (*Client) ChangeGroupForUser

func (c *Client) ChangeGroupForUser(openId string, groupId int) error

func (*Client) ChangeGroupForUsers

func (c *Client) ChangeGroupForUsers(openIds []string, groupId int) error

func (*Client) CloseAgentSession

func (c *Client) CloseAgentSession(account, openId, text string) (err error)

func (*Client) CorpSendCardByParties

func (c *Client) CorpSendCardByParties(card TextCard, partyIDs []string) error

func (*Client) CorpSendCardByTags

func (c *Client) CorpSendCardByTags(card TextCard, tagIDs []string) error

func (*Client) CorpSendCardByUsers

func (c *Client) CorpSendCardByUsers(card TextCard, userIDs []string) error

func (*Client) CorpSendCardToAll

func (c *Client) CorpSendCardToAll(card TextCard) error

func (*Client) CorpSendFileByParties

func (c *Client) CorpSendFileByParties(mediaID string, partyIDs []string) error

func (*Client) CorpSendFileByTags

func (c *Client) CorpSendFileByTags(mediaID string, tagIDs []string) error

func (*Client) CorpSendFileByUsers

func (c *Client) CorpSendFileByUsers(mediaID string, userIDs []string) error

func (*Client) CorpSendFileToAll

func (c *Client) CorpSendFileToAll(mediaID string) error

func (*Client) CorpSendImageByParties

func (c *Client) CorpSendImageByParties(mediaID string, partyIDs []string) error

func (*Client) CorpSendImageByTags

func (c *Client) CorpSendImageByTags(mediaID string, tagIDs []string) error

func (*Client) CorpSendImageByUsers

func (c *Client) CorpSendImageByUsers(mediaID string, userIDs []string) error

func (*Client) CorpSendImageToAll

func (c *Client) CorpSendImageToAll(mediaID string) error

func (*Client) CorpSendMPNewsByParties

func (c *Client) CorpSendMPNewsByParties(news CorpMPNews, partyIDs []string) error

func (*Client) CorpSendMPNewsByTags

func (c *Client) CorpSendMPNewsByTags(news CorpMPNews, tagIDs []string) error

func (*Client) CorpSendMPNewsByUsers

func (c *Client) CorpSendMPNewsByUsers(news CorpMPNews, userIDs []string) error

func (*Client) CorpSendMPNewsToAll

func (c *Client) CorpSendMPNewsToAll(news CorpMPNews) error

func (*Client) CorpSendNewsByParties

func (c *Client) CorpSendNewsByParties(news CorpNews, partyIDs []string) error

func (*Client) CorpSendNewsByTags

func (c *Client) CorpSendNewsByTags(news CorpNews, tagIDs []string) error

func (*Client) CorpSendNewsByUsers

func (c *Client) CorpSendNewsByUsers(news CorpNews, userIDs []string) error

func (*Client) CorpSendNewsToAll

func (c *Client) CorpSendNewsToAll(news CorpNews) error

func (*Client) CorpSendTextByParties

func (c *Client) CorpSendTextByParties(content string, partyIDs []string) error

func (*Client) CorpSendTextByTags

func (c *Client) CorpSendTextByTags(content string, tagIDs []string) error

func (*Client) CorpSendTextByUsers

func (c *Client) CorpSendTextByUsers(content string, userIDs []string) error

func (*Client) CorpSendTextToAll

func (c *Client) CorpSendTextToAll(content string) error

func (*Client) CorpSendVideoByParties

func (c *Client) CorpSendVideoByParties(video MPVideo, partyIDs []string) error

func (*Client) CorpSendVideoByTags

func (c *Client) CorpSendVideoByTags(video MPVideo, tagIDs []string) error

func (*Client) CorpSendVideoByUsers

func (c *Client) CorpSendVideoByUsers(video MPVideo, userIDs []string) error

func (*Client) CorpSendVideoToAll

func (c *Client) CorpSendVideoToAll(video MPVideo) error

func (*Client) CorpSendVoiceByParties

func (c *Client) CorpSendVoiceByParties(mediaID string, partyIDs []string) error

func (*Client) CorpSendVoiceByTags

func (c *Client) CorpSendVoiceByTags(mediaID string, tagIDs []string) error

func (*Client) CorpSendVoiceByUsers

func (c *Client) CorpSendVoiceByUsers(mediaID string, userIDs []string) error

func (*Client) CorpSendVoiceToAll

func (c *Client) CorpSendVoiceToAll(mediaID string) error

func (*Client) CreateAgent

func (c *Client) CreateAgent(account, nickname, password string, isPlain bool) (err error)

func (*Client) CreateAgentSession

func (c *Client) CreateAgentSession(account, openId, text string) (err error)

func (*Client) CreateConditionalMenu

func (c *Client) CreateConditionalMenu(menu *Menu) (menuID int64, err error)

func (*Client) CreateCorpMenu

func (c *Client) CreateCorpMenu(menu *Menu) error

func (*Client) CreateGroup

func (c *Client) CreateGroup(name string) (*Group, error)

func (*Client) CreateMenu

func (c *Client) CreateMenu(menu *Menu) error

func (*Client) CreateNews

func (c *Client) CreateNews(news *News) (mediaId string, err error)

func (*Client) DeleteAgent

func (c *Client) DeleteAgent(account string) (err error)

func (*Client) DeleteConditionalMenu

func (c *Client) DeleteConditionalMenu(menuID *Menu) error

func (*Client) DeleteCroup

func (c *Client) DeleteCroup(id string) error

func (*Client) DeleteMedia

func (c *Client) DeleteMedia(mediaId string) (err error)

func (*Client) DeleteMenu

func (c *Client) DeleteMenu() error

func (*Client) DeleteMsg

func (c *Client) DeleteMsg(msgId int64) error

DeleteMsg deletes the mass message(only MsgMPNews and MsgMPVideo) which was sent in half an hour. It invalidates the message content page, but still retains the message card.

func (*Client) DownloadFile

func (c *Client) DownloadFile(u URL, req interface{}, filePath string, rep interface{}) (err error)

func (*Client) DownloadMedia

func (c *Client) DownloadMedia(mediaId, filePath string) (err error)

func (*Client) DownloadTempMedia

func (c *Client) DownloadTempMedia(mediaId, filePath string) error

func (*Client) DownloadVideo

func (c *Client) DownloadVideo(mediaId, filePath string) (err error)

func (*Client) Get

func (c *Client) Get(u URL, rep interface{}) error

func (*Client) GetAgentMsgRecords

func (c *Client) GetAgentMsgRecords(timeSpan *TimeSpan, pageIndex int, pageSize ...int) (records []MsgRecord, err error)

func (*Client) GetAgentSessionForCustomer

func (c *Client) GetAgentSessionForCustomer(openId string) (session *AgentSession, err error)

func (*Client) GetAgentSessions

func (c *Client) GetAgentSessions(account string) (sessions []AgentSession, err error)

func (*Client) GetAgents

func (c *Client) GetAgents() (agents []Agent, err error)

func (*Client) GetCorpDepartmentList

func (c *Client) GetCorpDepartmentList(id ...int64) ([]CorpDepartment, error)

func (*Client) GetCorpUserList

func (c *Client) GetCorpUserList(departmentID int64, fetchChild ...bool) ([]CorpUser, error)

func (*Client) GetGroupByUser

func (c *Client) GetGroupByUser(openId string) (groupId int, err error)

func (*Client) GetGroups

func (c *Client) GetGroups() ([]Group, error)

func (*Client) GetMediaCounts

func (c *Client) GetMediaCounts() (mediaCounts *MediaCounts, err error)

func (*Client) GetMediaList

func (c *Client) GetMediaList(mediaType string, offset, count int) (mediaList *MediaList, err error)

func (*Client) GetMenus

func (c *Client) GetMenus() (menu *Menu, conditionalMenus []Menu, err error)

func (*Client) GetNews

func (c *Client) GetNews(mediaId string) (news *News, err error)

func (*Client) GetNewsList

func (c *Client) GetNewsList(offset, count int) (newsList *NewsList, err error)

func (*Client) GetOnlineAgents

func (c *Client) GetOnlineAgents() (agents []OnlineAgent, err error)

func (*Client) GetUser

func (c *Client) GetUser(openId string, lang ...string) (*User, error)

func (*Client) GetUserList

func (c *Client) GetUserList(nextId string) (*UserList, error)

func (*Client) GetUsers

func (c *Client) GetUsers(openIds []string, lang ...string) ([]User, error)

func (*Client) GetVideo

func (c *Client) GetVideo(mediaId string) (video *Video, err error)

func (*Client) GetWaitingAgentSessions

func (c *Client) GetWaitingAgentSessions() (totalCount int, sessions []AgentSession, err error)

func (*Client) IsMsgSent

func (c *Client) IsMsgSent(msgId int64) (bool, error)

func (*Client) Oauth2GetToken

func (c *Client) Oauth2GetToken(code, state string) (*Oauth2Token, error)

func (*Client) Oauth2GetTokenAndRedirect

func (c *Client) Oauth2GetTokenAndRedirect(code, state, redirectURL string) (string, error)

func (*Client) Oauth2GetUser

func (c *Client) Oauth2GetUser(token, openID string) (*Oauth2User, error)

func (*Client) Oauth2Redirect

func (c *Client) Oauth2Redirect(token *Oauth2Token, redirectURL string) (string, error)

func (*Client) Oauth2RefreshToken

func (c *Client) Oauth2RefreshToken(refreshToken string) (*Oauth2Token, error)

func (*Client) Post

func (c *Client) Post(u URL, req, rep interface{}) error

func (*Client) SendCardAll

func (c *Client) SendCardAll(cardId, cardExt string, tagID ...int) (id int, err error)

func (*Client) SendCardByUsers

func (c *Client) SendCardByUsers(cardId, cardExt string, userIds []string) (id int, err error)

func (*Client) SendCardForPreview

func (c *Client) SendCardForPreview(cardId, cardExt, wxName string) (id int, err error)

func (*Client) SendImageAll

func (c *Client) SendImageAll(mediaId string, tagID ...int) (id int, err error)

func (*Client) SendImageByUsers

func (c *Client) SendImageByUsers(mediaId string, userIds []string) (id int, err error)

func (*Client) SendImageForPreview

func (c *Client) SendImageForPreview(mediaId, wxName string) (id int, err error)

func (*Client) SendNewsAll

func (c *Client) SendNewsAll(mediaId string, tagID ...int) (id, dataId int, err error)

func (*Client) SendNewsByUsers

func (c *Client) SendNewsByUsers(mediaId string, userIds []string) (id, dataId int, err error)

func (*Client) SendNewsForPreview

func (c *Client) SendNewsForPreview(mediaId, wxName string) (id, dataId int, err error)

func (*Client) SendTemplateMessage

func (c *Client) SendTemplateMessage(msg *TemplateMsg, values ...map[string]string) (msgID int64, err error)

func (*Client) SendTextAll

func (c *Client) SendTextAll(content string, tagID ...int) (id int, err error)

func (*Client) SendTextByUsers

func (c *Client) SendTextByUsers(content string, userIds []string) (id int, err error)

func (*Client) SendTextForPreview

func (c *Client) SendTextForPreview(content, wxName string) (id int, err error)

func (*Client) SendVideoAll

func (c *Client) SendVideoAll(video MPVideo, tagID ...int) (id int, err error)

func (*Client) SendVideoByUsers

func (c *Client) SendVideoByUsers(video MPVideo, userIds []string) (id int, err error)

func (*Client) SendVideoForPreview

func (c *Client) SendVideoForPreview(video MPVideo, wxName string) (id int, err error)

func (*Client) SendVoiceAll

func (c *Client) SendVoiceAll(mediaId string, tagID ...int) (id int, err error)

func (*Client) SendVoiceByUsers

func (c *Client) SendVoiceByUsers(mediaId string, userIds []string) (id int, err error)

func (*Client) SendVoiceForPreview

func (c *Client) SendVoiceForPreview(mediaId, wxName string) (id int, err error)

func (*Client) UpdateAgent

func (c *Client) UpdateAgent(account, nickname, password string, isPlain bool) (err error)

func (*Client) UpdateGroup

func (c *Client) UpdateGroup(id string, name string) error

func (*Client) UpdateNews

func (c *Client) UpdateNews(mediaId string, index int, article *Article) (err error)

UpdateNews updates the index-th(0 based) article in the news which has media id mediaId.

func (*Client) UpdateUserRemark

func (c *Client) UpdateUserRemark(openId, remark string) error

func (*Client) UploadAgentHeadImage

func (c *Client) UploadAgentHeadImage(account, filePath string) (err error)

func (*Client) UploadFile

func (c *Client) UploadFile(u URL, name, filePath string, extraFields map[string]string, rep interface{}) error

func (*Client) UploadImage

func (c *Client) UploadImage(filePath string) (*Media, error)

func (*Client) UploadMedia

func (c *Client) UploadMedia(mediaType, filePath string, extraFields ...map[string]string) (*Media, error)

func (*Client) UploadTempImage

func (c *Client) UploadTempImage(filePath string) (*TempMedia, error)

func (*Client) UploadTempMedia

func (c *Client) UploadTempMedia(mediaType, filePath string) (*TempMedia, error)

func (*Client) UploadTempThumb

func (c *Client) UploadTempThumb(filePath string) (*TempMedia, error)

func (*Client) UploadTempVideo

func (c *Client) UploadTempVideo(filePath string) (*TempMedia, error)

func (*Client) UploadTempVoice

func (c *Client) UploadTempVoice(filePath string) (*TempMedia, error)

func (*Client) UploadThumb

func (c *Client) UploadThumb(filePath string) (*Media, error)

func (*Client) UploadVideo

func (c *Client) UploadVideo(title, intro, filePath string) (*Media, error)

func (*Client) UploadVoice

func (c *Client) UploadVoice(filePath string) (*Media, error)

type Context

type Context struct {
	*Client

	*Event
	// contains filtered or unexported fields
}

func (*Context) Abort

func (c *Context) Abort()

func (*Context) Next

func (c *Context) Next()

func (*Context) ReplyImage

func (ctx *Context) ReplyImage(mediaId string)

func (*Context) ReplyMusic

func (ctx *Context) ReplyMusic(music *Music)

func (*Context) ReplyNews

func (ctx *Context) ReplyNews(articles []ResponseArticle)

func (*Context) ReplyText

func (ctx *Context) ReplyText(content string)

func (*Context) ReplyTransferToAgent

func (ctx *Context) ReplyTransferToAgent(agentAccount ...string)

func (*Context) ReplyVideo

func (ctx *Context) ReplyVideo(mediaId, title, description string)

func (*Context) ReplyVoice

func (ctx *Context) ReplyVoice(mediaId string)

func (*Context) WriteResponse

func (c *Context) WriteResponse(rep interface{})

type CorpArticle

type CorpArticle struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	URL         string `json:"url"`
	PicURL      string `json:"picurl"`
	BtnTxt      string `json:"btntxt"`
}

type CorpDepartment

type CorpDepartment struct {
	ID       int64  `json:"id"`
	Name     string `json:"name"`
	ParentID int64  `json:"parentid"`
	Order    int64  `json:"order"`
}

type CorpErr

type CorpErr struct {
	Err
	InvalidUSer  string `json:"invaliduser"`
	InvalidParty string `json:"invalidparty"`
	InvalidTag   string `json:"invalidtag"`
}

func (*CorpErr) Error

func (err *CorpErr) Error() string

type CorpMPArticle

type CorpMPArticle struct {
	Title            string `json:"title"`
	Author           string `json:"author,omitempty"`
	ThumbId          string `json:"thumb_media_id"`               // media id of cover picture
	ContentSourceURL string `json:"content_source_url,omitempty"` // URL of "Read the original content"
	Content          string `json:"content"`                      // content, supporting HTML, no JS, less than 666KB
	Digest           string `json:"digest,omitempty"`             // content digest, less than 512B
}

type CorpMPNews

type CorpMPNews struct {
	Articles []CorpMPArticle `json:"articles"`
}

type CorpNews

type CorpNews struct {
	Articles []CorpArticle `json:"articles"`
}

type CorpUser

type CorpUser struct {
	ID         string  `json:"userid"`
	Name       string  `json:"name"`
	Department []int64 `json:"department"`
}

type Err

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

func (*Err) Code

func (err *Err) Code() int

func (*Err) Error

func (err *Err) Error() string

func (*Err) Msg

func (err *Err) Msg() string

type Error

type Error interface {
	error
	Code() int
	Msg() string
}

type Event

type Event struct {
	EventHeader

	Event string `xml:"Event" json:"Event"`

	MsgId        int     `xml:"MsgId"        json:"MsgId"`
	Content      string  `xml:"Content"      json:"Content"`
	MediaId      string  `xml:"MediaId"      json:"MediaId"`
	PicURL       string  `xml:"PicUrl"       json:"PicUrl"`
	Format       string  `xml:"Format"       json:"Format"`
	Recognition  string  `xml:"Recognition"  json:"Recognition"`
	ThumbMediaId string  `xml:"ThumbMediaId" json:"ThumbMediaId"`
	LocationX    float64 `xml:"Location_X"   json:"Location_X"`
	LocationY    float64 `xml:"Location_Y"   json:"Location_Y"`
	Scale        int     `xml:"Scale"        json:"Scale"`
	Label        string  `xml:"Label"        json:"Label"`
	Title        string  `xml:"Title"        json:"Title"`
	Description  string  `xml:"Description"  json:"Description"`
	URL          string  `xml:"Url"          json:"Url"`
	EventKey     string  `xml:"EventKey"     json:"EventKey"`
	Ticket       string  `xml:"Ticket"       json:"Ticket"`
	Latitude     float64 `xml:"Latitude"     json:"Latitude"`
	Longitude    float64 `xml:"Longitude"    json:"Longitude"`
	Precision    float64 `xml:"Precision"    json:"Precision"`

	MenuId       int `xml:"MenuId" json:"MenuId"`
	ScanCodeInfo *struct {
		ScanType   string `xml:"ScanType"   json:"ScanType"`
		ScanResult string `xml:"ScanResult" json:"ScanResult"`
	} `xml:"ScanCodeInfo,omitempty" json:"ScanCodeInfo,omitempty"`
	SendPicsInfo *struct {
		Count   int `xml:"Count" json:"Count"`
		PicList []struct {
			PicMd5Sum string `xml:"PicMd5Sum" json:"PicMd5Sum"`
		} `xml:"PicList>item,omitempty" json:"PicList,omitempty"`
	} `xml:"SendPicsInfo,omitempty" json:"SendPicsInfo,omitempty"`
	SendLocationInfo *struct {
		LocationX float64 `xml:"Location_X" json:"Location_X"`
		LocationY float64 `xml:"Location_Y" json:"Location_Y"`
		Scale     int     `xml:"Scale"      json:"Scale"`
		Label     string  `xml:"Label"      json:"Label"`
		PoiName   string  `xml:"Poiname"    json:"Poiname"`
	} `xml:"SendLocationInfo,omitempty" json:"SendLocationInfo,omitempty"`

	Status string `xml:"Status" json:"Status"`

	*AgentSessionChange

	ChosenBeacon  *Beacon `xml:"ChosenBeacon,omitempty" json:"ChosenBeacon,omitempty"`
	AroundBeacons *Beacon `xml:"AroundBeacons>AroundBeacon,omitempty" json:"AroundBeacons,omitempty"`
}

type EventHeader

type EventHeader struct {
	ToUser      string `xml:"ToUserName"   json:"ToUserName"`
	FromUser    string `xml:"FromUserName" json:"FromUserName"`
	CreatedTime int64  `xml:"CreateTime"   json:"CreateTime"`
	Type        string `xml:"MsgType"      json:"MsgType"`
}

type File

type File struct {
	MediaId string `json:"media_id"`
}

type Group

type Group struct {
	Id        int    `json:"id"`
	Name      string `json:"name"`
	UserCount int    `json:"count"`
}

type Handler

type Handler func(*Context)

type Image

type Image struct {
	MediaId string `json:"media_id"`
}

type MP

type MP struct {
	*Server
	*Client
	CorpClient *Client
}

func New

func New(id, appID, appSecret, token, aesKey string, urlPrefix ...string) *MP

type MPVideo

type MPVideo struct {
	MediaId     string `json:"media_id"`
	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`
}

type MatchRule

type MatchRule struct {
	GroupID            *int64 `json:"group_id,omitempty"`
	Sex                *int   `json:"sex,omitempty"`
	Country            string `json:"country,omitempty"`
	Province           string `json:"province,omitempty"`
	City               string `json:"city,omitempty"`
	ClientPlatformType *int   `json:"client_platform_type,omitempty"`
	Language           string `json:"language,omitempty"`
}

type Media

type Media struct {
	Id         string `json:"media_id"`
	URL        string `json:"url"`         // only nonempty when media type is Image or Thumb, and only available on *.qq.com
	Name       string `json:"name"`        // only nonempty when call GetMediaList
	UpdateTime int64  `json:"update_time"` // only nonempty when call GetMediaList
}

Permanent media

type MediaCounts

type MediaCounts struct {
	VoiceCount int `json:"voice_count"`
	VideoCount int `json:"video_count"`
	ImageCount int `json:"image_count"`
	NewsCount  int `json:"news_count"`
}

type MediaList

type MediaList struct {
	TotalCount int     `json:"total_count"`
	ItemCount  int     `json:"item_count"` // item count of this time GetMediaList
	Items      []Media `json:"item"`
}
type Menu struct {
	Buttons   []*Button  `json:"button,omitempty"`
	MatchRule *MatchRule `json:"matchrule,omitempty"`
	MenuId    int64      `json:"menuid,omitempty"`
}

type MsgFilter

type MsgFilter struct {
	IsToAll bool `json:"is_to_all,omitempty"`
	TagID   int  `json:"tag_id,omitempty"`
}

type MsgRecord

type MsgRecord struct {
	Agent     string `json:"worker"` // agent account
	OpenId    string `json:"openid"`
	OpCode    int    `json:"opercode"`
	Timestamp int64  `json:"time"` // UNIX timestamp
	Text      string `json:"text"` // message text
}

type Music

type Music struct {
	Title       string `xml:"Title,omitempty"`
	Description string `xml:"Description,omitempty"`
	URL         string `xml:"MusicUrl"`
	HQURL       string `xml:"HQMusicUrl"`
	ThumbId     string `xml:"ThumbMediaId"`
}

type News

type News struct {
	Articles []Article `json:"articles,omitempty"`
}

type NewsList

type NewsList struct {
	TotalCount int `json:"total_count"`
	ItemCount  int `json:"item_count"` // item count of this time GetNewsList
	Items      []struct {
		Id         string `json:"media_id"`
		UpdateTime int64  `json:"update_time"`
		Content    struct {
			Articles []Article `json:"news_item,omitempty"`
		} `json:"content"`
	} `json:"item"`
}

type Oauth2Token

type Oauth2Token struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int64  `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	OpenID       string `json:"openid"`
	Scope        string `json:"scope"`
	State        string `json:"state,omitempty"`
}

type Oauth2User

type Oauth2User struct {
	OpenID     string   `json:"openid"`
	Nickname   string   `json:"nickname"`
	Sex        int      `json:"sex"`
	Province   string   `json:"province"`
	City       string   `json:"city"`
	Country    string   `json:"country"`
	HeadImgURL string   `json:"headimgurl"`
	Privilege  []string `json:"privilege	"`
	UnionID    string   `json:"unionid"`
}

type OnlineAgent

type OnlineAgent struct {
	Id                int64  `json:"kf_id"`
	Account           string `json:"kf_account"`    // identifier@account
	Status            int    `json:"status"`        // 1: PC Online, 2: Mobile Online, 3: PC and Mobile Online
	AutoAcceptNum     int    `json:"auto_accept"`   // maximum number of auto accepting
	AcceptedCaseCount int    `json:"accepted_case"` // count of accepted cases
}

Online Customer Service Agent

type OpenId

type OpenId string

type ResponseArticle

type ResponseArticle struct {
	Title       string `xml:"Title"`
	Description string `xml:"Description"`
	PicURL      string `xml:"PicUrl"`
	URL         string `xml:"Url"`
}

type Server

type Server struct {
	*mel.Mel

	ID string // Wechat ID
	// contains filtered or unexported fields
}

func NewServer

func NewServer(token, aesKey string, urlPrefix ...string) *Server

func (*Server) GetAESKey

func (srv *Server) GetAESKey() (string, string)

func (*Server) GetToken

func (srv *Server) GetToken() (string, string)

func (*Server) GetVerifyFile

func (srv *Server) GetVerifyFile(filename string, content []byte)

func (*Server) HandleEvent

func (srv *Server) HandleEvent(eventType string, handler Handler)

func (*Server) HandleMessage

func (srv *Server) HandleMessage(msgType string, handler Handler)

func (*Server) SetAESKey

func (srv *Server) SetAESKey(base64AESKey string)

func (*Server) SetAppID

func (srv *Server) SetAppID(appID string)

func (*Server) SetClient

func (srv *Server) SetClient(client *Client)

func (*Server) SetID

func (srv *Server) SetID(id string)

func (*Server) SetToken

func (srv *Server) SetToken(token string)

func (*Server) Use

func (srv *Server) Use(middlewares ...Handler)

type TempMedia

type TempMedia struct {
	Type      string `json:"type"`
	Id        string `json:"media_id"`
	CreatedAt int64  `json:"created_at"`
}

Temporary media

type TemplateMsg

type TemplateMsg struct {
	ToUser      string `json:"touser"`
	TemplateID  string `json:"template_id"`
	URL         string `json:"url,omitempty"`
	MiniProgram struct {
		AppID    string `json:"appid"`
		PagePath string `json:"pagepath"`
	} `json:"miniprogram,omitempty"`
	Data map[string]TemplateMsgValue `json:"data"`
}

type TemplateMsgValue

type TemplateMsgValue struct {
	Value string `json:"value"`
	Color string `json:"color,omitempty"`
}

type Text

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

type TextCard

type TextCard struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	URL         string `json:"url"`
	BtnTxt      string `json:"btntxt"`
}

type TimeSpan

type TimeSpan struct {
	StartTime int64 `json:"starttime"` // UNIX timestamp
	EndTime   int64 `json:"endtime"`   // UNIX timestamp; EndTime-StartTime <= 24 hours
}

func NewTimeSpanAfter

func NewTimeSpanAfter(start time.Time, duration time.Duration) *TimeSpan

func NewTimeSpanBefore

func NewTimeSpanBefore(end time.Time, duration time.Duration) *TimeSpan

type Token

type Token struct {
	// contains filtered or unexported fields
}

type TokenAccessor

type TokenAccessor struct {
	// contains filtered or unexported fields
}

func NewCorpTokenAccessor

func NewCorpTokenAccessor(corpID, corpSecret string) (ta *TokenAccessor)

func NewTokenAccessor

func NewTokenAccessor(appId, appSecret string, needsTicket bool) (ta *TokenAccessor)

func (*TokenAccessor) RefreshTicket

func (ta *TokenAccessor) RefreshTicket(usedTicket string) (ticket string, err error)

func (*TokenAccessor) RefreshToken

func (ta *TokenAccessor) RefreshToken(usedToken string) (token string, err error)

func (*TokenAccessor) Start

func (ta *TokenAccessor) Start()

func (*TokenAccessor) Stop

func (ta *TokenAccessor) Stop()

func (*TokenAccessor) Ticket

func (ta *TokenAccessor) Ticket() (ticket string, err error)

func (*TokenAccessor) Token

func (ta *TokenAccessor) Token() (token string, err error)

type URL

type URL string
var BASE_URL URL = "https://api.weixin.qq.com/cgi-bin"
var CORP_BASE_URL URL = "https://qyapi.weixin.qq.com/cgi-bin"

func (URL) Join

func (u URL) Join(segment string) URL

func (URL) Query

func (u URL) Query(key, value string) URL

type User

type User struct {
	IsSubscriber  int    `json:"subscribe"` // 0 represents not a subscriber and the following infos do not exist
	OpenID        string `json:"openid"`
	Nickname      string `json:"nickname"`
	Sex           int    `json:"sex"`      // 1: male, 2: female, 3: unknown
	Language      string `json:"language"` // zh_CN, zh_TW, en
	City          string `json:"city"`
	Province      string `json:"province"`
	Country       string `json:"country"`
	HeadImageURL  string `json:"headimgurl"`
	SubscribeTime int64  `json:"subscribe_time"`
	UnionID       string `json:"unionid,omitempty"` // exists only when the WeChat public account has been bound to WeChat open platform account
	Remark        string `json:"remark"`
	GroupID       int    `json:"groupid"`
}

type UserList

type UserList struct {
	Total int `json:"total"`
	Count int `json:"count"`

	Data struct {
		Ids []string `json:"openid,omitempty"`
	} `json:"data"`

	NextId string `json:"next_openid"`
}

type Video

type Video struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	URL         string `json:"down_url"`
}

type Voice

type Voice struct {
	MediaId string `json:"media_id"`
}

Jump to

Keyboard shortcuts

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