Documentation ¶
Index ¶
- Constants
- func DeleteBroadcast(accessToken string, msgID, index int) error
- func DeleteTemplate(accessToken, templateId string) error
- func GetBroadcastSpeedDesc(level BroadcastSpeedLevel) string
- func GetModuleID(accessToken, shortID string) (string, error)
- func SetBroadcastSpeed(accessToken string, speed BroadcastSpeedLevel) error
- type ArticleArr
- type ArticleInfo
- type ArticleMsg
- type BroadcastMsg
- func (bm *BroadcastMsg) AddUsers(openIDs ...string)
- func (bm *BroadcastMsg) ClearUsers(msgType BroadcastMsgType)
- func (bm *BroadcastMsg) SendAll(accessToken string) (*BroadcastResult, error)
- func (bm *BroadcastMsg) SendPreview(accessToken string) (*BroadcastResult, error)
- func (bm *BroadcastMsg) SendToUsers(accessToken string) (*BroadcastResult, error)
- func (bm *BroadcastMsg) SetBroadcastMsgType(msgType BroadcastMsgType)
- func (bm *BroadcastMsg) SetClientMsgID(msgID string)
- func (bm *BroadcastMsg) SetIgnoreReprint(ignore bool)
- func (bm *BroadcastMsg) SetImage(mediaID string)
- func (bm *BroadcastMsg) SetMpNews(mediaID string)
- func (bm *BroadcastMsg) SetPreviewUser(openID string)
- func (bm *BroadcastMsg) SetPreviewWxName(wxName string)
- func (bm *BroadcastMsg) SetTagFilter(isTtoAll bool, tagId int)
- func (bm *BroadcastMsg) SetText(content string)
- func (bm *BroadcastMsg) SetVideo(mediaID string)
- func (bm *BroadcastMsg) SetVoice(mediaID string)
- func (bm *BroadcastMsg) SetWxCard(cardID string)
- func (bm *BroadcastMsg) SetWxCardWithExt(cardID string, ext *CardExt)
- type BroadcastMsgType
- type BroadcastResult
- type BroadcastSpeedInfo
- type BroadcastSpeedLevel
- type BroadcastStatus
- type CardExt
- type CardInfo
- type KeFuMsg
- func (msg *KeFuMsg) SendMsg(accessToken string) error
- func (msg *KeFuMsg) SetImageInfo(mediaID string)
- func (msg *KeFuMsg) SetMemus(headContent, tailContent string, menus ...*MenuInfo)
- func (msg *KeFuMsg) SetMiniProgramPage(title, appid, pagePath, thubmmeidiaID string)
- func (msg *KeFuMsg) SetMpNew(mediaId string)
- func (msg *KeFuMsg) SetMsgType(msgType KeFuMsgType)
- func (msg *KeFuMsg) SetMusicInfo(title, desc, url, hqUrl, thumbMediaID string)
- func (msg *KeFuMsg) SetNews(title, desc, url, picUrl string)
- func (msg *KeFuMsg) SetSendKeFu(kfAccount string)
- func (msg *KeFuMsg) SetTextInfo(content string)
- func (msg *KeFuMsg) SetToUser(openID string)
- func (msg *KeFuMsg) SetVideoInfo(mediaID, thumbMediaID, title, desc string)
- func (msg *KeFuMsg) SetVoiceInfo(mediaID string)
- func (msg *KeFuMsg) SetWxCard(cardId string)
- type KeFuMsgType
- type MediaInfo
- type MediaMsg
- type MenuInfo
- type MenuMsg
- type MiniProgramInfo
- type MiniProgramPage
- type MsgKeFu
- type MsgTagFilter
- type MusicInfo
- type MusicMsg
- type RespImageMsg
- type RespVideoMsg
- type RespVoiceMsg
- type ResponseMsg
- func (rm *ResponseMsg) SetArticles(articles ...*media.NewsItem)
- func (rm *ResponseMsg) SetContent(content string)
- func (rm *ResponseMsg) SetImage(meidaId string)
- func (rm *ResponseMsg) SetMsgType(msgType ResponseMsgType)
- func (rm *ResponseMsg) SetMusic(title, desc, url, hqUrl, thumbMediaID string)
- func (rm *ResponseMsg) SetToUser(openID string)
- func (rm *ResponseMsg) SetVideo(mediaId, title, desc string)
- func (rm *ResponseMsg) SetVoice(mediaId string)
- func (rm *ResponseMsg) ToXml() ([]byte, error)
- type ResponseMsgType
- type SubscribeMsg
- func (sm *SubscribeMsg) Send(accessToken string) error
- func (sm *SubscribeMsg) SetJumpMiniProgram(mini *MiniProgramPage)
- func (sm *SubscribeMsg) SetJumpUrl(url string)
- func (sm *SubscribeMsg) SetMsgData(data *TemplateMsgContent)
- func (sm *SubscribeMsg) SetTemplateID(tempID string)
- func (sm *SubscribeMsg) SetToUser(openID string)
- type TemplateData
- type TemplateInfo
- type TemplateList
- type TemplateMsg
- func (tm *TemplateMsg) Send(accessToken string) (int64, error)
- func (tm *TemplateMsg) SetJumpMiniProgram(mini *MiniProgramPage)
- func (tm *TemplateMsg) SetJumpUrl(url string)
- func (tm *TemplateMsg) SetMsgData(data *TemplateData)
- func (tm *TemplateMsg) SetTemplateID(tempID string)
- func (tm *TemplateMsg) SetToUser(openID string)
- type TemplateMsgContent
- type TextInfo
- type TextMsg
- type VideoInfo
- type VideoMsg
- type WechatMsg
- func (wxmsg *WechatMsg) IsEventMsg() bool
- func (wxmsg *WechatMsg) IsImageMsg() bool
- func (wxmsg *WechatMsg) IsLinkMsg() bool
- func (wxmsg *WechatMsg) IsLocationMsg() bool
- func (wxmsg *WechatMsg) IsShortVideoMsg() bool
- func (wxmsg *WechatMsg) IsTextMsg() bool
- func (wxmsg *WechatMsg) IsVideoMsg() bool
- func (wxmsg *WechatMsg) IsVoiceMsg() bool
- type WxCardInfo
Constants ¶
const ( BroadcastByOpenIDUrl = "https://api.weixin.qq.com/cgi-bin/message/mass/send?access_token=%s" BroadcastByTagUrl = "https://api.weixin.qq.com/cgi-bin/message/mass/sendall?access_token=%s" DeleteBroadcastUrl = "https://api.weixin.qq.com/cgi-bin/message/mass/delete?access_token=%s" SendPreviewUrl = "https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=%s" CheckBroadcastStatusUrl = "https://api.weixin.qq.com/cgi-bin/message/mass/get?access_token=%s" CheckBroadcastSpeedUrl = "https://api.weixin.qq.com/cgi-bin/message/mass/speed/get?access_token=%s" SetBroadcastSpeedUrl = "https://api.weixin.qq.com/cgi-bin/message/mass/speed/set?access_token=%s" )
在返回成功时,意味着群发任务提交成功,并不意味着此时群发已经结束,所以,仍有可能在后续的发送过程中出现异常情况导致用户未收到消息,如消息有时会进行审核、服务器不稳定等。 此外,群发任务一般需要较长的时间才能全部发送完毕,请耐心等待。
const ( BroadcastMsgOfText BroadcastMsgType = "text" BroadcastMsgOfNews = "mpnews" BroadcastMsgOfVoice = "voice" BroadcastMsgOfImage = "image" BroadcastMsgOfVideo = "mpvideo" BroadcastMsgOfWxCard = "wxcard" )
const ( BroadcastStatusSendSuccess BroadcastStatus = "SEND_SUCCESS" BroadcastStatusSending = "SENDING" BroadcastStatusSendFail = "SEND_FAIL" BroadcastStatusSendDeleted = "DELETE" )
const ( BroadcastSpeed0 BroadcastSpeedLevel = 0 BroadcastSpeed1 = 1 BroadcastSpeed2 = 2 BroadcastSpeed3 = 3 BroadcastSpeed4 = 4 )
const ( KeFuMsgOfText KeFuMsgType = "text" KeFuMsgOfImage = "image" KeFuMsgOfVoice = "voice" KeFuMsgOfVideo = "video" KeFuMsgOfMusic = "music" KeFuMsgOfNews = "news" KeFuMsgOfMpNews = "mpnews" KeFuMsgOfMenu = "msgmenu" KeFuMsgOfWxCard = "wxcard" KeFuMsgOfMiniProgram = "miniprogrampage" )
const ( ResponseMsgOfText ResponseMsgType = "text" ResponseMsgOfImage = "image" ResponseMsgOfVoice = "voice" ResponseMsgOfVideo = "video" ResponseMsgOfMusic = "music" ResponseMsgOfNews = "news" )
const ( GetTemplateIDUrl = "https://api.weixin.qq.com/cgi-bin/template/api_add_template?access_token=%s" GetTemplateListUrl = "https://api.weixin.qq.com/cgi-bin/template/get_all_private_template?access_token=%s" DeleteTemplateUrl = "https://api.weixin.qq.com/cgi-bin/template/del_private_template?access_token=%s" SendTemplatMsgUrl = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=%s" )
const ( WechatMsgOfText = "text" WechatMsgOfImage = "image" WechatMsgOfVoice = "voice" WechatMsgOfVideo = "video" WechatMsgOfShortVideo = "shortvideo" WechatMsgOfLocation = "location" WechatMsgOfLink = "link" WechatMsgOfEvent = "event" )
微信推送消息类型
const ( //用户在关注与取消关注公众号时,微信会把这个事件推送到开发者填写的URL。方便开发者给用户下发欢迎消息或者做帐号的解绑。 //为保护用户数据隐私,开发者收到用户取消关注事件时需要删除该用户的所有信息。 //微信服务器在五秒内收不到响应会断掉连接,并且重新发起请求,总共重试三次。 //关于重试的消息排重,推荐使用FromUserName + CreateTime 排重 EventOfSubscribe = "subscribe" EventOfUnSubscribe = "unsubscribe" //用户扫描带场景值二维码时 //如果用户还未关注公众号,则用户可以关注公众号,关注后微信会将带场景值关注事件推送给开发者 Event为subscribe //如果用户已经关注公众号,则微信会将带场景值扫描事件推送给开发者 Event为scan EventOfScan = "scan" EventOfLocation = "location" EventOfClick = "click" //点击菜单拉取消息时的事件推送 EventOfView = "view" //点击菜单跳转链接时的事件推送 EventOfScanCodePush = "scancode_push" //扫码推事件的事件推送 EventOfScanCodeWaitMsg = "scancode_waitmsg" //扫码推事件且弹出“消息接收中”提示框的事件推送 EventOfPicSysPhoto = "pic_sysphoto" //弹出系统拍照发图的事件推送 EventOfPicPhotoOrAlbum = "pic_photo_or_album" //弹出拍照或者相册发图的事件推送 EventOfPicWeixin = "pic_weixin" //弹出微信相册发图器的事件推送 EventOfLocationSelect = "location_select" //弹出地理位置选择器的事件推送 EventOfMiniProgram = "view_miniprogram" //点击菜单跳转小程序的事件推送 //下面是微信认证事件 EventOfQualificationVerifySuccss = "qualification_verify_success" //资质认证成功(此时立即获得接口权限) EventOfQualificationVerifyFail = "qualification_verify_fail" //资质认证失败 EventOfNamingVerifySuccess = "naming_verify_success" //名称认证成功(即命名成功) EventOfNamingVerifyFail = "naming_verify_fail" //名称认证失败(这时虽然客户端不打勾,但仍有接口权限) EventOfAnnualReNew = "annual_renew" //年审通知 EventOfVerifyExpired = "verify_expired" //认证过期失效通知审通知 )
消息类型为event时的时间类型 某些事件推送在发生后,是允许开发者回复用户的,某些则不允许
const (
KeFuMsgApi = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=%s"
)
const (
SendSubscribeMsgUrl = "https://api.weixin.qq.com/cgi-bin/message/template/subscribe?access_token=%s"
)
Variables ¶
This section is empty.
Functions ¶
func DeleteBroadcast ¶
1、只有已经发送成功的消息才能删除 2、删除消息是将消息的图文详情页失效,已经收到的用户,还是能在其本地看到消息卡片。 3、删除群发消息只能删除图文消息和视频消息,其他类型的消息一经发送,无法删除。 4、如果多次群发发送的是一个图文消息,那么删除其中一次群发,就会删除掉这个图文消息也,导致所有群发都失效
func DeleteTemplate ¶
func GetBroadcastSpeedDesc ¶
func GetBroadcastSpeedDesc(level BroadcastSpeedLevel) string
func GetModuleID ¶
func SetBroadcastSpeed ¶
func SetBroadcastSpeed(accessToken string, speed BroadcastSpeedLevel) error
Types ¶
type ArticleArr ¶
type ArticleArr struct {
Articles []*ArticleMsg `json:"articles,omitempty"`
}
type ArticleInfo ¶
type ArticleInfo struct { Title string `xml:"Title"` //图文消息标题 Description string `xml:"Description"` //图文消息描述 PicUrl string `xml:"PicUrl"` //图片链接,支持JPG、PNG格式,较好的效果为大图360*200,小图200*200 Url string `xml:"Url"` //点击图文消息跳转链接 }
func NewArticleInfo ¶
func NewArticleInfo(title, description, picUrl, url string) *ArticleInfo
type ArticleMsg ¶
type BroadcastMsg ¶
type BroadcastMsg struct { ToUser string `json:"touser,omitempty"` //预览时候使用,制定预览人的openid ToWxName string `json:"towxname,omitempty"` //发送指定微信号预览 ClientMsgId string `json:"clientmsgid,omitempty"` //开发者侧群发msgid,用于避免重复推送,长度限制64字节,如不填,则后台默认以群发范围和群发内容的摘要值做为clientmsgid MsgType BroadcastMsgType `json:"msgtype,omitempty"` SendIgnoreReprint int `json:"send_ignore_reprint,omitempty"` //图文消息被判定为转载时,是否继续群发。 1为继续群发(转载),0为停止群发。 该参数默认为0。 //根据标签群发的过滤器 Filter *MsgTagFilter `json:"filter,omitempty"` //用于设定图文消息的接收者 //根据openid列表群发的过滤器 ToUsers []string `json:"touser,omitempty"` News *MediaInfo `json:"mpnews,omitempty"` //用于设定即将发送的图文消息 Text *TextInfo `json:"text,omitempty"` Voice *MediaInfo `json:"voice,omitempty"` Video *MediaInfo `json:"mpvideo,omitempty"` WxCard *WxCardInfo `json:"wxcard,omitempty"` // contains filtered or unexported fields }
func (*BroadcastMsg) AddUsers ¶
func (bm *BroadcastMsg) AddUsers(openIDs ...string)
func (*BroadcastMsg) ClearUsers ¶
func (bm *BroadcastMsg) ClearUsers(msgType BroadcastMsgType)
func (*BroadcastMsg) SendAll ¶
func (bm *BroadcastMsg) SendAll(accessToken string) (*BroadcastResult, error)
func (*BroadcastMsg) SendPreview ¶
func (bm *BroadcastMsg) SendPreview(accessToken string) (*BroadcastResult, error)
func (*BroadcastMsg) SendToUsers ¶
func (bm *BroadcastMsg) SendToUsers(accessToken string) (*BroadcastResult, error)
func (*BroadcastMsg) SetBroadcastMsgType ¶
func (bm *BroadcastMsg) SetBroadcastMsgType(msgType BroadcastMsgType)
func (*BroadcastMsg) SetClientMsgID ¶
func (bm *BroadcastMsg) SetClientMsgID(msgID string)
func (*BroadcastMsg) SetIgnoreReprint ¶
func (bm *BroadcastMsg) SetIgnoreReprint(ignore bool)
func (*BroadcastMsg) SetImage ¶
func (bm *BroadcastMsg) SetImage(mediaID string)
func (*BroadcastMsg) SetMpNews ¶
func (bm *BroadcastMsg) SetMpNews(mediaID string)
func (*BroadcastMsg) SetPreviewUser ¶
func (bm *BroadcastMsg) SetPreviewUser(openID string)
func (*BroadcastMsg) SetPreviewWxName ¶
func (bm *BroadcastMsg) SetPreviewWxName(wxName string)
func (*BroadcastMsg) SetTagFilter ¶
func (bm *BroadcastMsg) SetTagFilter(isTtoAll bool, tagId int)
若is_to_all值为true,可不填写tag_id
func (*BroadcastMsg) SetText ¶
func (bm *BroadcastMsg) SetText(content string)
func (*BroadcastMsg) SetVideo ¶
func (bm *BroadcastMsg) SetVideo(mediaID string)
func (*BroadcastMsg) SetVoice ¶
func (bm *BroadcastMsg) SetVoice(mediaID string)
func (*BroadcastMsg) SetWxCard ¶
func (bm *BroadcastMsg) SetWxCard(cardID string)
func (*BroadcastMsg) SetWxCardWithExt ¶
func (bm *BroadcastMsg) SetWxCardWithExt(cardID string, ext *CardExt)
type BroadcastMsgType ¶
type BroadcastMsgType string
type BroadcastResult ¶
type BroadcastSpeedInfo ¶
type BroadcastSpeedInfo struct { Speed int `json:"speed"` //群发速度的级别 RealSpeed int `json:"realspeed"` //群发速度的真实值 单位:万/分钟 }
func GetBroadcastSpeed ¶
func GetBroadcastSpeed(accessToken string) (*BroadcastSpeedInfo, error)
type BroadcastSpeedLevel ¶
type BroadcastSpeedLevel int
type BroadcastStatus ¶
type BroadcastStatus string
func CheckBroadcastStatus ¶
func CheckBroadcastStatus(accessToken string, msgId int) (BroadcastStatus, error)
type KeFuMsg ¶
type KeFuMsg struct { //这两个所有消息都哟 ToUser string `json:"touser,omitempty"` Msgtype KeFuMsgType `json:"msgtype,omitempty"` //如果需要以某个客服帐号来发消息(在微信6.0.2及以上版本中显示自定义头像),则需在JSON数据包的后半部分加入customservice参数 CustomService *MsgKeFu `json:"customservice,omitempty"` Text *TextMsg `json:"text,omitempty"` Image *MediaMsg `json:"image,omitempty"` Voice *MediaMsg `json:"voice,omitempty"` Video *VideoMsg `json:"video,omitempty"` Music *MusicMsg `json:"music,omitempty"` //发送图文消息(点击跳转到外链) 图文消息条数限制在1条以内,注意,如果图文数超过1,则将会返回错误码45008。 News ArticleArr `json:"news,omitempty"` //发送图文消息(点击跳转到图文消息页面) 图文消息条数限制在1条以内,注意,如果图文数超过1,则将会返回错误码45008。 MpNews *MediaMsg `json:"mpnews,omitempty"` MsgMenu *MenuMsg `json:"msgmenu,omitempty"` //特别注意客服消息接口投放卡券仅支持非自定义Code码和导入code模式的卡券的卡券,详情请见:是否自定义code码。 WxCard *CardInfo `json:"wxcard,omitempty"` //要求小程序与公众号已关联, MiniProgramPage *MiniProgramInfo `json:"miniprogrampage,omitempty"` }
func NewKeFuMsg ¶
func NewKeFuMsg() *KeFuMsg
func (*KeFuMsg) SetImageInfo ¶
func (*KeFuMsg) SetMiniProgramPage ¶
func (*KeFuMsg) SetMsgType ¶
func (msg *KeFuMsg) SetMsgType(msgType KeFuMsgType)
func (*KeFuMsg) SetMusicInfo ¶
func (*KeFuMsg) SetSendKeFu ¶
func (*KeFuMsg) SetTextInfo ¶
func (*KeFuMsg) SetVideoInfo ¶
func (*KeFuMsg) SetVoiceInfo ¶
type KeFuMsgType ¶
type KeFuMsgType string
type MediaInfo ¶
type MediaInfo struct {
MediaID string `xml:"MediaId"` //通过素材管理中的接口上传多媒体文件,得到的id。
}
type MiniProgramInfo ¶
type MiniProgramPage ¶
type MiniProgramPage struct { Appid string `json:"appid"` //所需跳转到的小程序appid(该小程序appid必须与发模板消息的公众号是绑定关联关系,暂不支持小游戏) PagePath string `json:"pagepath"` //所需跳转到小程序的具体页面路径,支持带参数,(示例index?foo=bar),要求该小程序已发布,暂不支持小游戏 }
func NewProgramPage ¶
func NewProgramPage(appid, pagePath string) *MiniProgramPage
type MsgTagFilter ¶
type RespImageMsg ¶
type RespVideoMsg ¶
type RespVoiceMsg ¶
type ResponseMsg ¶
type ResponseMsg struct { XMLName xml.Name `xml:"xml"` ToUserName string `xml:"ToUserName,omitempty"` //接收方帐号(收到的OpenID) FromUserName string `xml:"FromUserName,omitempty"` //开发者微信号 CreateTime int64 `xml:"CreateTime,omitempty"` //消息创建时间 (整型) MsgType ResponseMsgType `xml:"MsgType,omitempty"` //消息类型 Content string `xml:"Content,omitempty"` //回复的消息内容(换行:在content中能够换行,微信客户端就支持换行显示) Image *MediaInfo `xml:"Image,omitempty"` Voice *MediaInfo `xml:"Voice,omitempty"` Video *VideoInfo `xml:"Video,omitempty"` Music *MusicInfo `xml:"Music,omitempty"` ArticleCount int `xml:"ArticleCount,omitempty"` Articles []*media.NewsItem `xml:"Articles,omitempty"` }
func NewResponseMsg ¶
func NewResponseMsg(fromUser string) *ResponseMsg
func (*ResponseMsg) SetArticles ¶
func (rm *ResponseMsg) SetArticles(articles ...*media.NewsItem)
func (*ResponseMsg) SetContent ¶
func (rm *ResponseMsg) SetContent(content string)
func (*ResponseMsg) SetImage ¶
func (rm *ResponseMsg) SetImage(meidaId string)
func (*ResponseMsg) SetMsgType ¶
func (rm *ResponseMsg) SetMsgType(msgType ResponseMsgType)
func (*ResponseMsg) SetMusic ¶
func (rm *ResponseMsg) SetMusic(title, desc, url, hqUrl, thumbMediaID string)
func (*ResponseMsg) SetToUser ¶
func (rm *ResponseMsg) SetToUser(openID string)
func (*ResponseMsg) SetVideo ¶
func (rm *ResponseMsg) SetVideo(mediaId, title, desc string)
func (*ResponseMsg) SetVoice ¶
func (rm *ResponseMsg) SetVoice(mediaId string)
func (*ResponseMsg) ToXml ¶
func (rm *ResponseMsg) ToXml() ([]byte, error)
type ResponseMsgType ¶
type ResponseMsgType string
type SubscribeMsg ¶
type SubscribeMsg struct { ToUser string `json:"touser"` // 接收者openid TemplateID string `json:"template_id"` Url string `json:"url"` //模板跳转链接(海外帐号没有跳转能力) MiniProgramPage *MiniProgramPage `json:"miniprogram"` //跳小程序所需数据,不需跳小程序可不用传该数据 Sence string `json:"sence"` //订阅场景值 Title string `json:"title"` //消息标题,15字以内 Data *TemplateMsgContent `json:"data"` // }
func NewSubscribeMsg ¶
func NewSubscribeMsg() *SubscribeMsg
func (*SubscribeMsg) Send ¶
func (sm *SubscribeMsg) Send(accessToken string) error
func (*SubscribeMsg) SetJumpMiniProgram ¶
func (sm *SubscribeMsg) SetJumpMiniProgram(mini *MiniProgramPage)
func (*SubscribeMsg) SetJumpUrl ¶
func (sm *SubscribeMsg) SetJumpUrl(url string)
func (*SubscribeMsg) SetMsgData ¶
func (sm *SubscribeMsg) SetMsgData(data *TemplateMsgContent)
func (*SubscribeMsg) SetTemplateID ¶
func (sm *SubscribeMsg) SetTemplateID(tempID string)
func (*SubscribeMsg) SetToUser ¶
func (sm *SubscribeMsg) SetToUser(openID string)
type TemplateData ¶
type TemplateData struct { First *TemplateMsgContent `json:"first"` KeyWord1 *TemplateMsgContent `json:"keyword1"` KeyWord2 *TemplateMsgContent `json:"keyword2"` KeyWord3 *TemplateMsgContent `json:"keyword3"` Remark *TemplateMsgContent `json:"remark"` }
func (*TemplateData) SetFirst ¶
func (td *TemplateData) SetFirst(tmc *TemplateMsgContent)
func (*TemplateData) SetKeyWord1 ¶
func (td *TemplateData) SetKeyWord1(tmc *TemplateMsgContent)
func (*TemplateData) SetKeyWord2 ¶
func (td *TemplateData) SetKeyWord2(tmc *TemplateMsgContent)
func (*TemplateData) SetKeyWord3 ¶
func (td *TemplateData) SetKeyWord3(tmc *TemplateMsgContent)
func (*TemplateData) SetRemark ¶
func (td *TemplateData) SetRemark(tmc *TemplateMsgContent)
type TemplateInfo ¶
type TemplateInfo struct { TemplateID string `json:"template_id"` //模板ID Title string `json:"title"` //模板标题 PrimaryIndustry string `json:"primary_industry"` //模板所属行业的一级行业 DuputyIndustry string `json:"deputy_industry"` //模板所属行业的二级行业 Content string `json:"content"` //模板内容 Example string `json:"example"` //模板示例 }
type TemplateList ¶
type TemplateList struct {
// contains filtered or unexported fields
}
func GetModuleList ¶
func GetModuleList(accessToken string) (*TemplateList, error)
type TemplateMsg ¶
type TemplateMsg struct { ToUser string `json:"touser"` // 接收者openid TemplateID string `json:"template_id"` Url string `json:"url"` //模板跳转链接(海外帐号没有跳转能力) MiniProgramPage *MiniProgramPage `json:"miniprogram"` //跳小程序所需数据,不需跳小程序可不用传该数据 MsgData *TemplateData `json:"data"` }
url和miniprogram都是非必填字段,若都不传则模板无跳转; 若都传,会优先跳转至小程序。开发者可根据实际需要选择其中一种跳转方式即可。当用户的微信客户端版本不支持跳小程序时,将会跳转至url。
func NewTemplatMsg ¶
func NewTemplatMsg() *TemplateMsg
func (*TemplateMsg) SetJumpMiniProgram ¶
func (tm *TemplateMsg) SetJumpMiniProgram(mini *MiniProgramPage)
func (*TemplateMsg) SetJumpUrl ¶
func (tm *TemplateMsg) SetJumpUrl(url string)
func (*TemplateMsg) SetMsgData ¶
func (tm *TemplateMsg) SetMsgData(data *TemplateData)
func (*TemplateMsg) SetTemplateID ¶
func (tm *TemplateMsg) SetTemplateID(tempID string)
func (*TemplateMsg) SetToUser ¶
func (tm *TemplateMsg) SetToUser(openID string)
type TemplateMsgContent ¶
type TemplateMsgContent struct { Content string `json:"value"` //消息正文,value为消息内容文本(200字以内),没有固定格式,可用\n换行 Color string `json:"color"` //模板内容字体颜色,不填默认为黑色 }
func NewMsgContent ¶
func NewMsgContent(content string) *TemplateMsgContent
func (*TemplateMsgContent) SetColor ¶
func (mc *TemplateMsgContent) SetColor(color string) error
func (*TemplateMsgContent) SetContent ¶
func (mc *TemplateMsgContent) SetContent(content string)
type TextMsg ¶
type TextMsg struct {
Content string `json:"content,omitempty"`
}
发送文本消息时,支持插入跳小程序的文字链 <a href="http://www.qq.com" data-miniprogram-appid="appid" data-miniprogram-path="pages/index/index">点击跳小程序</a> 1.data-miniprogram-appid 项,填写小程序appid,则表示该链接跳小程序; 2.data-miniprogram-path项,填写小程序路径,路径与app.json中保持一致,可带参数; 3.对于不支持data-miniprogram-appid 项的客户端版本,如果有herf项,则仍然保持跳href中的网页链接; 4.data-miniprogram-appid对应的小程序必须与公众号有绑定关系。
type WechatMsg ¶
type WechatMsg struct { //所有类型消息都有的字段 ToUserName string `xml:"ToUserName"` //开发者微信号 FromUserName string `xml:"FromUserName"` //发送方帐号(一个OpenID) CreateTime int64 `xml:"CreateTime"` //消息创建时间 (整型) MsgType string `xml:"MsgType"` //消息类型, MsgID int64 `xml:"MsgId"` //消息id,64位整型 //image,voice,vedio,shotvideo消息共有字段 MediaID string `xml:"MediaId"` //图片消息媒体id,可以调用获取临时素材接口拉取数据。 //text消息字段 Content string `xml:"Content"` //文本消息内容 //image消息字段 PicUrl string `xml:"PicUrl"` //图片链接(由系统生成) //voice消息字段 开通语音识别后,用户每次发送语音给公众号时,微信会在推送的语音消息XML数据包中,增加一个Recognition字段 Format string `xml:"Format"` //语音格式,如amr,speex等 Recognition string `xml:"Recognition"` //语音识别结果 //video,shortvideo共有字段 ThumbMediaID string `xml:"ThumbMediaId"` //视频消息缩略图媒体id,可以调用多媒体文件下载接口拉取数据。 //location消息以及location_select事件消息字段 LocationX float32 `xml:"Location_X"` //维度 LocationY float32 `xml:"Location_Y"` //经度 Scale int `xml:"Scale"` //地图缩放大小 Label string `xml:"Label"` //地理位置信息 //link消息字段 Title string `xml:"Title"` //消息标题 Description string `xml:"Description"` //消息描述 Url string `xml:"Url"` //消息链接 //以下字段事件类型消息专有 Event string `xml:"Event"` //扫描二维码事件字段 UnSubEventKey string `xml:"UnSubEventKey"` //扫码前未关注公众号,事件KEY值,qrscene_为前缀,后面为二维码的参数值 SubEventKey uint32 `xml:"SubEventKey"` //扫码前已关注公众号,一个32位无符号整数,即创建二维码时的二维码scene_id Ticket string `xml:"Ticket"` //二维码的ticket,可用来换取二维码图片 //上报地理位置字段 Latitude float32 `xml:"Latitude"` //地理位置纬度 Longitude float32 `xml:"Longitude"` //地理位置经度 Precision float32 `xml:"Precision"` //地理位置精度 //自定义菜单事件字段 //自定义事件共存字段 EventKey string `xml:"EventKey"` //扫码推事件的事件推送,事件KEY值,由开发者在创建菜单时设定 //view,view_miniprogram事件字段 MenuID int64 `xml:"MenuID"` //指菜单ID,如果是个性化菜单,则可以通过这个字段,知道是哪个规则的菜单被点击了。 //scancode_push、scancode_waitmsg事件字段 ScanCodeInfo string `xml:"ScanCodeInfo"` //扫描信息 ScanType string `xml:"ScanType"` //扫描类型,一般是qrcode ScanResult string `xml:"ScanResult"` //扫描结果,即二维码对应的字符串信息 //pic_sysphoto,pic_photo_or_album,pic_weixin事件字段 SendPicsInfo string `xml:"SendPicsInfo"` //发送的图片信息 Count int `xml:"Count"` //发送的图片数量 PicList string `xml:"PicList"` //图片列表 PicMd5Sum string `xml:"PicMd5Sum"` //图片的MD5值,开发者若需要,可用于验证接收到图片 //location_select事件字段 SendLocationInfo string `xml"SendLocationInfo"` //发送的位置信息 Poiname string `xml:"Poiname"` //朋友圈POI的名字,可能为空 //通过客服接口发送菜单消息,用户点击后,会收到text消息,其中包含该字段 MenuMsgID string `xml:"bizmsgmenuid,omitempty"` //认证事件有该参数 ExpiredTime int64 `xml:"ExpiredTime"` //有效期 (整形),指的是时间戳,将于该时间戳认证过期 FailTime int64 `xml:"FailTime"` //失败发生时间 (整形),时间戳 FailReason string `xml:"FailReason"` //认证失败的原因 }