Documentation ¶
Index ¶
- Constants
- type AccessToken
- type Article
- type ArticlesReply
- type AuthToken
- type Button
- func ClickButton(name, key string) Button
- func GroupButton(name string) Button
- func LocationSelectButton(name, key string) Button
- func MPButton(name, appid, pagepath string, url ...string) Button
- func MediaButton(name, mediaID string) Button
- func PicPhotoOrAlbum(name, key string) Button
- func PicSysphotoButton(name, key string) Button
- func PicWeixin(name, key string) Button
- func ScancodePushButton(name, key string) Button
- func ScancodeWaitMsgButton(name, key string) Button
- func ViewButton(name, url string) Button
- func ViewLimitedButton(name, mediaID string) Button
- type CgiBin
- type ConditionalMenu
- type DefaultMenu
- type EventMsg
- type ImageReply
- type JSAPITicket
- type Menu
- func (m *Menu) Create(accessToken string, btns ...Button) error
- func (m *Menu) CreateConditional(accessToken string, matchRule *MenuMatchRule, btns ...Button) error
- func (m *Menu) Delete(accessToken string) error
- func (m *Menu) DeleteConditional(accessToken, menuID string) error
- func (m *Menu) GetList(accessToken string) (*MenuList, error)
- type MenuButton
- type MenuList
- type MenuMatchRule
- type Message
- type MsgBody
- type MsgCrypt
- type MusicReply
- type Reply
- func (r *Reply) Articles(count int, articles ...*Article) (*ReplyMsg, error)
- func (r *Reply) Image(mediaID string) (*ReplyMsg, error)
- func (r *Reply) Music(mediaID, title, desc, url, HQUrl string) (*ReplyMsg, error)
- func (r *Reply) Text(content string) (*ReplyMsg, error)
- func (r *Reply) Transfer2KF(kfAccount ...string) (*ReplyMsg, error)
- func (r *Reply) Video(mediaID, title, desc string) (*ReplyMsg, error)
- func (r *Reply) Voice(mediaID string) (*ReplyMsg, error)
- type ReplyHeader
- type ReplyMsg
- type Sns
- type Subscriber
- type SubscriberInfo
- type SubscriberList
- type TextReply
- type TplMsg
- type TransInfo
- type Transfer2KF
- type User
- type VideoReply
- type VoiceReply
- type WXPub
- func (wx *WXPub) CgiBin(options ...utils.HTTPRequestOption) *CgiBin
- func (wx *WXPub) Menu(options ...utils.HTTPRequestOption) *Menu
- func (wx *WXPub) Message(options ...utils.HTTPRequestOption) *Message
- func (wx *WXPub) MsgCrypt(cipherMsg string) *MsgCrypt
- func (wx *WXPub) Reply(openid string) *Reply
- func (wx *WXPub) Sns(options ...utils.HTTPRequestOption) *Sns
- func (wx *WXPub) Subscriber(options ...utils.HTTPRequestOption) *Subscriber
Constants ¶
const ( CgiBinAccessTokenURL = "https://api.weixin.qq.com/cgi-bin/token" CgiBinTicketURL = "https://api.weixin.qq.com/cgi-bin/ticket/getticket" )
cgi-bin
const ( MenuCreateURL = "https://api.weixin.qq.com/cgi-bin/menu/create" MenuAddConditionalURL = "https://api.weixin.qq.com/cgi-bin/menu/addconditional" MenuListURL = "https://api.weixin.qq.com/cgi-bin/menu/get" MenuDeleteURL = "https://api.weixin.qq.com/cgi-bin/menu/delete" MenuDeleteConditionalURL = "https://api.weixin.qq.com/cgi-bin/menu/delconditional" )
menu
const ( SnsCode2Token = "https://api.weixin.qq.com/sns/oauth2/access_token" SnsCheckAccessTokenURL = "https://api.weixin.qq.com/sns/auth" SnsRefreshAccessTokenURL = "https://api.weixin.qq.com/sns/oauth2/refresh_token" SnsUserInfoURL = "https://api.weixin.qq.com/sns/userinfo" )
sns
const ( SubscriberGetURL = "https://api.weixin.qq.com/cgi-bin/user/info" SubscriberBatchGetURL = "https://api.weixin.qq.com/cgi-bin/user/info/batchget" SubscriberListURL = "https://api.weixin.qq.com/cgi-bin/user/get" )
subscriber
const DefaultReply = "success"
DefaultReply 公众号默认回复
const MaxSubscriberListCount = 10000
MaxSubscriberListCount 公众号订阅者列表的最大数目
const (
TplMsgSendURL = "https://api.weixin.qq.com/cgi-bin/message/template/send"
)
msg
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶
AccessToken wxpub access_token
type Article ¶
type Article struct { Title utils.CDATA `xml:"Title"` // 图文消息标题 Description utils.CDATA `xml:"Description"` // 图文消息描述 PicURL utils.CDATA `xml:"PicUrl"` // 图片链接, 支持JPG, PNG格式, 较好的效果为大图360*200, 小图200*200 URL utils.CDATA `xml:"Url"` // 点击图文消息跳转链接 }
Article 公众号图文
type ArticlesReply ¶
type ArticlesReply struct { XMLName xml.Name `xml:"xml"` ReplyHeader ArticleCount int `xml:"ArticleCount"` // 图文消息个数, 限制为10条以内 Articles []*Article `xml:"Articles>item"` // 多条图文消息信息, 默认第一个item为大图, 注意, 如果图文数超过10, 则将会无响应 }
Articles 公众号图文回复
type AuthToken ¶
type AuthToken struct { AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` ExpiresIn int64 `json:"expires_in"` OpenID string `json:"openid"` Scope string `json:"scope"` }
AuthToken 公众号授权Token
type Button ¶
type Button interface {
AddSubButton(btn ...Button)
}
Button 菜单按钮
func LocationSelectButton ¶
LocationSelectButton 发送位置按钮
func ScancodePushButton ¶
ScancodePushButton 扫码推事件按钮
func ScancodeWaitMsgButton ¶
ScancodeWaitMsgButton 扫码带提示按钮
func ViewLimitedButton ¶
ViewLimitedButton 图文消息按钮
type CgiBin ¶
type CgiBin struct {
// contains filtered or unexported fields
}
CgiBin cgi-bin
func (*CgiBin) GetAccessToken ¶
func (c *CgiBin) GetAccessToken() (*AccessToken, error)
GetAccessToken returns access_token
type ConditionalMenu ¶
type ConditionalMenu struct { Button []*MenuButton `json:"button"` MenuID int64 `json:"menuid"` MatchRule *MenuMatchRule `json:"matchrule"` }
type DefaultMenu ¶
type DefaultMenu struct { Button []*MenuButton `json:"button"` MenuID int64 `json:"menuid"` }
type EventMsg ¶
type EventMsg struct { ToUserName string `xml:"ToUserName"` FromUserName string `xml:"FromUserName"` CreateTime int64 `xml:"CreateTime"` MsgType string `xml:"MsgType"` MsgID int64 `xml:"MsgId"` Content string `xml:"Content"` PicURL string `xml:"PicUrl"` MediaID string `xml:"MediaId"` Format string `xml:"Format"` Recognition string `xml:"Recognition"` ThumbMediaID string `xml:"ThumbMediaId"` LocationX float64 `xml:"Location_X"` LocationY float64 `xml:"Location_Y"` Scale int `xml:"Scale"` Label string `xml:"Label"` Title string `xml:"Title"` Description string `xml:"Description"` URL string `xml:"Url"` Event string `xml:"Event"` EventKey string `xml:"EventKey"` Ticket string `xml:"Ticket"` Latitude float64 `xml:"Latitude"` Longitude float64 `xml:"Longitude"` Precision float64 `xml:"Precision"` }
EventMsg 微信公众号事件消息
type ImageReply ¶
type ImageReply struct { XMLName xml.Name `xml:"xml"` ReplyHeader Image struct { MediaID utils.CDATA `xml:"MediaId"` // 通过素材管理接口上传多媒体文件得到 MediaId } `xml:"Image"` }
ImageReply 公众号图片回复
type JSAPITicket ¶
JSAPITicket wxpub js api ticket
type Menu ¶
type Menu struct {
// contains filtered or unexported fields
}
Menu 公众号菜单
func (*Menu) CreateConditional ¶
func (m *Menu) CreateConditional(accessToken string, matchRule *MenuMatchRule, btns ...Button) error
CreateConditional 创建个性化菜单
func (*Menu) DeleteConditional ¶
DeleteConditional 删除个性化菜单
type MenuButton ¶
type MenuButton struct { Type string `json:"type"` Name string `json:"name"` Key string `json:"key,omitempty"` URL string `json:"url,omitempty"` AppID string `json:"appid,omitempty"` PagePath string `json:"page_path,omitempty"` MediaID string `json:"media_id,omitempty"` SubButton []*MenuButton `json:"sub_button,omitempty"` }
type MenuList ¶
type MenuList struct { DefaultMenu *DefaultMenu `json:"menu"` ConditionalMenu []*ConditionalMenu `json:"conditionalmenu"` }
type MenuMatchRule ¶
type MsgCrypt ¶
type MsgCrypt struct {
// contains filtered or unexported fields
}
MsgCrypt 公众号消息解析
func (*MsgCrypt) Decrypt ¶
Decrypt 消息解密,参考微信[加密解密技术方案](https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419318482&token=&lang=zh_CN)
type MusicReply ¶
type MusicReply struct { XMLName xml.Name `xml:"xml"` ReplyHeader Music struct { Title utils.CDATA `xml:"Title,omitempty"` // 音乐标题 Description utils.CDATA `xml:"Description,omitempty"` // 音乐描述 MusicURL utils.CDATA `xml:"MusicUrl,omitempty"` // 音乐链接 HQMusicURL utils.CDATA `xml:"HQMusicUrl,omitempty"` // 高质量音乐链接, WIFI环境优先使用该链接播放音乐 ThumbMediaID utils.CDATA `xml:"ThumbMediaId"` // 通过素材管理接口上传多媒体文件得到 ThumbMediaId } `xml:"Music"` }
Music 公众号音乐回复
type Reply ¶
type Reply struct {
// contains filtered or unexported fields
}
Reply 公众号回复
func (*Reply) Transfer2KF ¶
Transfer2KF transfer msg to wxpub kf
type ReplyHeader ¶
type ReplyHeader struct { ToUserName utils.CDATA `xml:"ToUserName"` FromUserName utils.CDATA `xml:"FromUserName"` CreateTime int64 `xml:"CreateTime"` MsgType utils.CDATA `xml:"MsgType"` }
ReplyHeader 公众号消息回复公共头
type ReplyMsg ¶
type ReplyMsg struct { XMLName xml.Name `xml:"xml"` Encrypt utils.CDATA `xml:"Encrypt"` MsgSignature utils.CDATA `xml:"MsgSignature"` TimeStamp int64 `xml:"TimeStamp"` Nonce utils.CDATA `xml:"Nonce"` }
ReplyMsg 公众号回复消息
type Sns ¶
type Sns struct {
// contains filtered or unexported fields
}
Sns sns
func (*Sns) CheckAccessToken ¶
CheckAccessToken 校验授权AccessToken是否有效
func (*Sns) Code2Token ¶
Code2Token 获取公众号授权AccessToken
func (*Sns) GetUserInfo ¶
GetUserInfo 获取微信用户信息
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber 微信公众号订阅者
func (*Subscriber) BatchGet ¶
func (s *Subscriber) BatchGet(accessToken string, openid ...string) ([]*SubscriberInfo, error)
BatchGet 批量获取微信公众号订阅者信息
func (*Subscriber) Get ¶
func (s *Subscriber) Get(accessToken, openid string) (*SubscriberInfo, error)
GetSubscriberInfo 获取微信公众号订阅者信息
func (*Subscriber) GetList ¶
func (s *Subscriber) GetList(accessToken string, nextOpenID ...string) (*SubscriberList, error)
GetList 获取微信公众号订阅者列表
type SubscriberInfo ¶
type SubscriberInfo struct { Subscribe int `json:"subscribe"` OpenID string `json:"openid"` NickName string `json:"nickName"` Sex int `json:"sex"` Language string `json:"language"` City string `json:"city"` Province string `json:"province"` Country string `json:"country"` AvatarURL string `json:"headimgurl"` SubscribeTime int64 `json:"subscribe_time"` UnionID string `json:"unionid"` Remark string `json:"remark"` GroupID int64 `json:"groupid"` TagidList []int64 `json:"tagid_list"` SubscribeScene string `json:"subscribe_scene"` QRScene int64 `json:"qr_scene"` QRSceneStr string `json:"qr_scene_str"` }
SubscriberInfo 微信公众号订阅者信息
type SubscriberList ¶
type SubscriberList struct { Total int `json:"total"` Count int `json:"count"` Data map[string][]string `json:"data"` NextOpenID string `json:"next_openid"` }
SubscriberList 微信公众号订阅者列表
type TextReply ¶
type TextReply struct { XMLName xml.Name `xml:"xml"` ReplyHeader Content utils.CDATA `xml:"Content"` }
TextReply 公众号文本回复
type TplMsg ¶
type TplMsg struct { OpenID string // 接收者(用户)的 openid TplID string // 模板ID RedirectURL string // 模板跳转链接(海外帐号没有跳转能力) MPAppID string // 所需跳转到的小程序appid(该小程序appid必须与发模板消息的公众号是绑定关联关系,暂不支持小游戏) MPPagePath string // 所需跳转到小程序的具体页面路径,支持带参数,(示例index?foo=bar),要求该小程序已发布,暂不支持小游戏 Data MsgBody // 模板内容,格式形如:{"key1": {"value": any}, "key2": {"value": any}} Color string // 模板内容字体颜色,不填默认为黑色 }
TplMsg 公众号模板消息
type Transfer2KF ¶
type Transfer2KF struct { XMLName xml.Name `xml:"xml"` ReplyHeader TransInfo *TransInfo `xml:"TransInfo,omitempty"` }
Transfer2KF 公众号消息转客服
type User ¶
type User struct { OpenID string `json:"openid"` UnionID string `json:"unionid"` Nickname string `json:"nickname"` Gender int `json:"sex"` Province string `json:"province"` City string `json:"city"` Country string `json:"country"` Avatar string `json:"headimgurl"` Privilege []string `json:"privilege"` }
User 微信用户信息
type VideoReply ¶
type VideoReply struct { XMLName xml.Name `xml:"xml"` ReplyHeader Video struct { MediaID utils.CDATA `xml:"MediaId"` // 通过素材管理接口上传多媒体文件得到 MediaId Title utils.CDATA `xml:"Title,omitempty"` // 视频消息的标题, 可以为空 Description utils.CDATA `xml:"Description,omitempty"` // 视频消息的描述, 可以为空 } `xml:"Video" json:"Video"` }
Video 公众号视频回复
type VoiceReply ¶
type VoiceReply struct { XMLName xml.Name `xml:"xml"` ReplyHeader Voice struct { MediaID utils.CDATA `xml:"MediaId"` // 通过素材管理接口上传多媒体文件得到 MediaId } `xml:"Voice"` }
VoiceReply 公众号语音回复
type WXPub ¶
type WXPub struct { AccountID string AppID string AppSecret string SignToken string EncodingAESKey string Client *utils.HTTPClient }
WXPub 微信公众号
func (*WXPub) CgiBin ¶
func (wx *WXPub) CgiBin(options ...utils.HTTPRequestOption) *CgiBin
CgiBin returns new cgi-bin
func (*WXPub) Menu ¶
func (wx *WXPub) Menu(options ...utils.HTTPRequestOption) *Menu
Menu returns new menu
func (*WXPub) Message ¶
func (wx *WXPub) Message(options ...utils.HTTPRequestOption) *Message
Message returns new tpl msg
func (*WXPub) Sns ¶
func (wx *WXPub) Sns(options ...utils.HTTPRequestOption) *Sns
Sns returns new sns
func (*WXPub) Subscriber ¶
func (wx *WXPub) Subscriber(options ...utils.HTTPRequestOption) *Subscriber
Subscriber returns new subscriber