Documentation ¶
Overview ¶
公众号模板消息
Index ¶
- Constants
- Variables
- type ArticleItem
- type Button
- func LoadMenu(jsonstr []byte) ([]Button, error)
- func LoadMenuFromFile(path string) ([]Button, error)
- func NewButtonArticle(name, mediaid string) Button
- func NewButtonClick(name, key string) Button
- func NewButtonLocation(name, key string) Button
- func NewButtonMedia(name, mediaid string) Button
- func NewButtonMiniApp(name, appid, pagepath, uri string) Button
- func NewButtonPhoto(name, key string) Button
- func NewButtonPhotoOrAlbum(name, key string) Button
- func NewButtonScanPush(name, key string) Button
- func NewButtonScanWait(name, key string) Button
- func NewButtonView(name, url string) Button
- func NewButtonWXPic(name, key string) Button
- func NewParentMenu(name string) Button
- type CDataContent
- type CSMsgReply
- type JSSDKSignature
- type MatchRule
- func (m MatchRule) MatchCity(city string) MatchRule
- func (m MatchRule) MatchCountry(country string) MatchRule
- func (m MatchRule) MatchLanguage(language string) MatchRule
- func (m MatchRule) MatchProvince(province string) MatchRule
- func (m MatchRule) MatchSex(sex WXSexType) MatchRule
- func (m MatchRule) MatchTag(tagid string) MatchRule
- type MediaObject
- type OptionFunc
- type PicInfo
- type StuffType
- type TmplData
- type TmplMessageSendReply
- type WXArticleMsgResponse
- type WXBoolType
- type WXClient
- func (c *WXClient) APPID() string
- func (c *WXClient) BatchGetUserInfo(openids ...string) ([]WXUserInfo, error)
- func (c *WXClient) CheckSignature(qryArgs url.Values) (string, error)
- func (c *WXClient) ClearMenu() error
- func (c *WXClient) CreateMenu(items ...Button) error
- func (c *WXClient) CreatePersonalMenu(rule MatchRule, items ...Button) (string, error)
- func (c *WXClient) CreateQRCode(sceneValue interface{}, seconds int) (io.Reader, error)
- func (c *WXClient) DeletePersonalMenu(menuid string) error
- func (c *WXClient) DownloadHQVoice(mediaid string) (MediaObject, error)
- func (c *WXClient) DownloadMedia(mediaid string) (MediaObject, error)
- func (c *WXClient) DownloadVideo(mediaid string) (string, error)
- func (c *WXClient) EnableDebug()
- func (c *WXClient) GenJSAPISign(u *url.URL) (JSSDKSignature, error)
- func (c *WXClient) GetUserInfo(openid string) (user WXUserInfo, err error)
- func (c *WXClient) MessageHandleFunc(handler func(WXMessageRequest) WXMessageResponse)
- func (c *WXClient) SendCSMsg(msg CSMsgReply) error
- func (c *WXClient) SendTmplMessage(data *TmplData) (int64, error)
- func (c *WXClient) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (c *WXClient) ServerGin(ctx *gin.Context)
- func (c *WXClient) TestPersonalMenu(wxuserid string) ([]Button, error)
- func (c *WXClient) UploadTempStuff(t StuffType, filename string, file io.Reader) (string, error)
- func (c *WXClient) UploadTempStuffFile(t StuffType, filename string) (string, error)
- type WXEventType
- type WXImgMsgResponse
- type WXMessageHandler
- type WXMessageOKResponse
- type WXMessageRequest
- type WXMessageResponse
- type WXMessageType
- type WXMsgResponse
- type WXMusicMsgResponse
- type WXSexType
- type WXTextMsgResponse
- type WXTransferCSResponse
- type WXUserInfo
- type WXVideoMsgResponse
- type WXVoiceMsgResponse
Constants ¶
const (
// PermanentQRCode 永久二维码
PermanentQRCode = 0
)
Variables ¶
var ErrNoTokenServer = errors.New("No specify token server")
Functions ¶
This section is empty.
Types ¶
type ArticleItem ¶
type ArticleItem struct { Title CDataContent Description CDataContent PicUrl CDataContent Url CDataContent }
ArticleItem 图文消息文章列表
type Button ¶
type Button map[string]interface{}
Button 菜单
func LoadMenuFromFile ¶
LoadMenuFromFile 从文件中加载菜单配置
func NewButtonClick ¶
NewButtonClick creates click button
func NewButtonMiniApp ¶
NewButtonMiniApp 打开小程序按钮 appid: 小程序的appid(仅认证公众号可配置) pagepath: 小程序的页面路径 参数uri: 网页 链接,用户点击菜单可打开链接,不超过1024字节。不支持小程序的老版本客户端将打开本url。
func NewButtonPhotoOrAlbum ¶
NewButtonPhotoOrAlbum 拍照或相册按钮
type CDataContent ¶
type CDataContent struct {
Text string `xml:",cdata"`
}
type CSMsgReply ¶
type CSMsgReply struct {
// contains filtered or unexported fields
}
CSMsgReply 客服消息
func (CSMsgReply) WithVideo ¶
func (reply CSMsgReply) WithVideo(mediaid, thumbMediaid, title, desc string)
WithVideo 视频消息
type JSSDKSignature ¶
JSSDKSignature JSSDK 签名对象
type MatchRule ¶
MatchRule 个性化菜单匹配规则
func (MatchRule) MatchCountry ¶
MatchCountry 国家匹配
func (MatchRule) MatchLanguage ¶
MatchLanguage 匹配语言
func (MatchRule) MatchProvince ¶
MatchProvince 匹配省份
type MediaObject ¶
type MediaObject struct { FileName string Type string Data io.ReadCloser Size int64 }
MediaObject 多媒体对象
type OptionFunc ¶
type OptionFunc func(*WXClient)
OptionFunc 配置函数
func WithValidationToken ¶
func WithValidationToken(token string) OptionFunc
type PicInfo ¶
type PicInfo struct { Count int `xml:",omitempty"` MD5SumItems []string `xml:"PicList>item>PicMd5Sum,omitempty"` }
PicInfo 发送的图片信息
type TmplData ¶
type TmplData struct { ToUser string `json:"touser"` TemplateID string `json:"template_id"` URL string `json:"url"` FontColor string `json:"color"` Data map[string]tmplFieldData `json:"data"` MiniApp struct { AppID string `json:"appid"` PagePath string `json:"pagepath"` } `json:"miniprogram"` }
TmplData 模板数据
func (*TmplData) LinkMiniApp ¶
LinkMiniApp 设置模板消息跳转至的小程序
type TmplMessageSendReply ¶
type TmplMessageSendReply struct { ErrCode int `json:"errcode"` ErrMsg string `json:"errmsg"` MsgID int64 `json:"msgid"` }
TmplMessageSendReply 模板消息发送结果
type WXArticleMsgResponse ¶
type WXArticleMsgResponse struct { WXMsgResponse ArticleCount int Articles []ArticleItem `xml:"Articles>item"` }
WXArticleMsgResponse 图文消息
func NewArticleMsg ¶
func NewArticleMsg(from, to string, items ...ArticleItem) WXArticleMsgResponse
NewArticleMsg 图文消息
type WXBoolType ¶
type WXBoolType byte
type WXClient ¶
type WXClient struct {
// contains filtered or unexported fields
}
WXClient 公众号客户端
func NewWXClient ¶
func NewWXClient(appid string, options ...OptionFunc) *WXClient
NewWXClient 创建公众号客户端
func (*WXClient) BatchGetUserInfo ¶
func (c *WXClient) BatchGetUserInfo(openids ...string) ([]WXUserInfo, error)
BatchGetUserInfo 批量获取用户信息
func (*WXClient) CheckSignature ¶
CheckSignature 微信接入验证
func (*WXClient) CreatePersonalMenu ¶
CreatePersonalMenu 创建个性化菜单
func (*WXClient) CreateQRCode ¶
CreateQRCode 创建二维码
func (*WXClient) DeletePersonalMenu ¶
DeletePersonalMenu 删除个性化菜单
func (*WXClient) DownloadHQVoice ¶
func (c *WXClient) DownloadHQVoice(mediaid string) (MediaObject, error)
DownloadHQVoice 下载高清语音文件 格式为speex,16K采样率
func (*WXClient) DownloadMedia ¶
func (c *WXClient) DownloadMedia(mediaid string) (MediaObject, error)
DownloadMedia 下载多媒体文件
func (*WXClient) DownloadVideo ¶
DownloadVideo 下载视频文件,返回视频链接
func (*WXClient) GenJSAPISign ¶
func (c *WXClient) GenJSAPISign(u *url.URL) (JSSDKSignature, error)
GenJSAPISign 生成JSSDK签名
func (*WXClient) GetUserInfo ¶
func (c *WXClient) GetUserInfo(openid string) (user WXUserInfo, err error)
GetUserInfo 获取用户基本信息
func (*WXClient) MessageHandleFunc ¶
func (c *WXClient) MessageHandleFunc(handler func(WXMessageRequest) WXMessageResponse)
MessageHandleFunc 消息处理函数
func (*WXClient) SendTmplMessage ¶
SendTmplMessage 发送模板消息
func (*WXClient) ServeHTTP ¶
func (c *WXClient) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP 自定义消息处理器
func (*WXClient) TestPersonalMenu ¶
TestPersonalMenu 测试个性化菜单 wxuserid 可以是粉丝的OpenID,也可以是粉丝的微信号
func (*WXClient) UploadTempStuff ¶
UploadTempStuff 上传临时素材
type WXEventType ¶
type WXEventType string
WXEventType 事件类型
const ( EventTypeSubscribe WXEventType = "subscribe" EventTypeUnsubscribe WXEventType = "unsubscribe" EventTypeScan WXEventType = "SCAN" EventTypeLocation WXEventType = "LOCATION" EventTypeClick WXEventType = "CLICK" EventTypeView WXEventType = "VIEW" // 自定义菜单事件 EventTypeScanPush WXEventType = "scancode_push" EventTypeScanWait WXEventType = "scancode_waitmsg" EventTypePhoto WXEventType = "pic_sysphoto" EventTypePhotoOrAlbum WXEventType = "pic_photo_or_album" EventTypePicWeiXin WXEventType = "pic_weixin" EventTypeLocationSelect WXEventType = "location_select" )
事件类型定义
type WXImgMsgResponse ¶
type WXImgMsgResponse struct { WXMsgResponse MediaID CDataContent `xml:"Image>MediaId,omitempty"` }
WXImgMsgResponse 图片体消息
type WXMessageHandler ¶
type WXMessageHandler func(WXMessageRequest) WXMessageResponse
WXMessageHandler 消息处理器
type WXMessageRequest ¶
type WXMessageRequest struct { XMLName xml.Name `xml:"xml"` ToUserName string `xml:",omitempty"` FromUserName string `xml:",omitempty"` CreateTime int64 `xml:",omitempty"` MsgType WXMessageType `xml:",omitempty"` Content string `xml:",omitempty"` MsgId int64 `xml:",omitempty"` PicUrl string `xml:",omitempty"` MediaId string `xml:",omitempty"` ThumbMediaId string `xml:",omitempty"` //视频消息缩略图的媒体id,可以调用多媒体文件下载接口拉取数据。 Format string `xml:",omitempty"` Recognition string `xml:",omitempty"` //语音识别结果,UTF8编码 Location_X float64 `xml:",omitempty"` Location_Y float64 `xml:",omitempty"` Scale int `xml:",omitempty"` //地图缩放大小 Poiname, Label string `xml:",omitempty"` // 地理位置信息 Title string `xml:",omitempty"` Description string `xml:",omitempty"` Url string `xml:",omitempty"` Event WXEventType `xml:",omitempty"` EventKey string `xml:",omitempty"` Ticket string `xml:",omitempty"` Latitude, Longitude, Precision float64 `xml:",omitempty"` ScanCodeInfo, ScanType, ScanResult string `xml:",omitempty"` SendPicsInfo PicInfo `xml:",omitempty"` }
WXMessageRequest 微信消息
func (WXMessageRequest) GetEventKey ¶
func (r WXMessageRequest) GetEventKey() string
GetEventKey 返回EventKey
func (WXMessageRequest) IsScanEvent ¶
func (r WXMessageRequest) IsScanEvent() bool
IsScanEvent 消息是否为扫码事件
type WXMessageType ¶
type WXMessageType string
WXMessageType 微信消息类型
const ( WXMsgTypeEvent WXMessageType = "event" WXMsgTypeText WXMessageType = "text" WXMsgTypeImage WXMessageType = "image" WXMsgTypeVoice WXMessageType = "voice" WXMsgTypeVideo WXMessageType = "video" WXMsgTypeShortVideo WXMessageType = "shortvideo" WXMsgTypeLink WXMessageType = "link" WXMsgTypeLocation WXMessageType = "location" WXMsgTypeMusic WXMessageType = "music" WXMsgTypeNews WXMessageType = "news" WXMsgTypeTransferCS WXMessageType = "transfer_customer_service" )
微信消息类型定义
type WXMsgResponse ¶
type WXMusicMsgResponse ¶
type WXMusicMsgResponse struct { WXMsgResponse Music struct { Title CDataContent `xml:",omitempty"` Description CDataContent `xml:",omitempty"` MusicURL CDataContent `xml:",omitempty"` HQMusicUrl CDataContent `xml:",omitempty"` ThumbMediaId CDataContent `xml:",omitempty"` } `xml:"Music"` }
WXMusicMsgResponse 音乐消息
func NewMusicMsg ¶
func NewMusicMsg(from, to, mediaid, title, desc, uri, hquri string) WXMusicMsgResponse
NewMusicMsg 音乐消息
type WXTextMsgResponse ¶
type WXTextMsgResponse struct { WXMsgResponse Content CDataContent `xml:",omitempty"` }
WXTextMsgResponse 回复微信消息
type WXTransferCSResponse ¶
type WXTransferCSResponse struct { WXMsgResponse Account CDataContent `xml:"TransInfo>KfAccount,omitempty"` }
WXTransferCSResponse 转发消息至微信客服系统
func TransferCustomerService ¶
func TransferCustomerService(from, to, account string) WXTransferCSResponse
TransferCustomerService 创建转发客服系统响应
type WXUserInfo ¶
type WXUserInfo struct { Subscribe WXBoolType `json:"subscribe"` OpenID string `json:"openid"` NickName string `json:"nickname"` Sex WXSexType `json:"sex"` Language string `json:"language"` City string `json:"city"` Province string `json:"province"` Country string `json:"country"` HeadImgUrl string `json:"headimgurl"` SubscribeTime dtime.JSONTime `json:"subscribe_time"` UnionID string `json:"unionid"` Remark string `json:"remark"` GroupID int `json:"groupid"` TagIDList []int `json:"tagid_list"` ErrCode int `json:"errcode"` ErrMsg string `json:"errmsg"` }
WXUserInfo 微信公众号用户基本信息
type WXVideoMsgResponse ¶
type WXVideoMsgResponse struct { WXMsgResponse MediaID CDataContent `xml:"Video>MediaId,omitempty"` Title CDataContent `xml:"Video>Title,omitempty"` Description CDataContent `xml:"Video>Description,omitempty"` }
WXVideoMsgResponse 视频消息
func NewVideoMsg ¶
func NewVideoMsg(from, to, mediaid, title, desc string) WXVideoMsgResponse
NewVideoMsg 视频消息
type WXVoiceMsgResponse ¶
type WXVoiceMsgResponse struct { WXMsgResponse MediaID CDataContent `xml:"Voice>MediaId,omitempty"` }
WXVoiceMsgResponse 语音体消息