Documentation ¶
Index ¶
- Constants
- func AccessTokenUrl(appid, secret string) string
- func CheckSignature(checkSignatureToken, timestamp, nonce string) (string, error)
- func CodeUrl(appid, redirectUri string) string
- func GenQrcodeUrl(accessToken string) string
- func GenReplyNewsMsgXml(memberOpenid, gzhOpenid, title, description, picUrl, url string) string
- func GenReplyTextMsgXml(memberOpenid, gzhOpenid, content string) string
- func GenScanEventTextMsgXml(memberOpenid, gzhOpenid, content string) string
- func GetJsapiTicketUrl(accessToken string) string
- func GetOpenidUrl(appid, secret, code string) string
- func GetQrcodeImageUrl(ticket string) string
- func GetWxUserInfoUrl(userAccessToken, openid string) string
- func GetWxUserInfoUrlByManager(gzhAccessToken, openid string) string
- type AccessTokenInfo
- type GetReplyMsgXml
- type GetScanEventMsgXml
- type JsapiTicketAuthSign
- type JsapiTicketData
- type OpenidInfo
- type QrcodeInfo
- type ServerSignatureInfo
- type UserInfo
- type UserInfoByManager
- type WxRespErr
Constants ¶
const ( MSGTYPE_SUBSCRIBE = "subscribe" // 关注 MSGTYPE_UNSUBSCRIBE = "unsubscribe" // 取消关注 MSGTYPE_SCAN = "SCAN" // 扫码 MSGTYPE_TEXT = "text" // 用户向公众号发消息 MSGTYPE_VIEW = "VIEW" )
Variables ¶
This section is empty.
Functions ¶
func AccessTokenUrl ¶
AccessTokenUrl 获取access_token
func CheckSignature ¶
CheckSignature 验签 @param checkSignatureToken string 微信平台的服务器验签token
func GenReplyNewsMsgXml ¶
GenScanSentNewsXmlMessage 被动回复用户消息:生成发送news消息 <xml> <ToUserName><![CDATA[toUser]]></ToUserName> <FromUserName><![CDATA[fromUser]]></FromUserName> <CreateTime>12345678</CreateTime> <MsgType><![CDATA[news]]></MsgType> <ArticleCount>1</ArticleCount> <Articles> <item> <Title><![CDATA[title1]]></Title> <Description><![CDATA[description1]]></Description> <PicUrl><![CDATA[picurl]]></PicUrl> <Url><![CDATA[url]]></Url> </item> </Articles> </xml>
func GenReplyTextMsgXml ¶
GenReplyTextMsgXml 被动回复用户消息:生成发送text消息 <xml> <ToUserName><![CDATA[toUser]]></ToUserName> <FromUserName><![CDATA[fromUser]]></FromUserName> <CreateTime>12345678</CreateTime> <MsgType><![CDATA[text]]></MsgType> <Content><![CDATA[你好]]></Content> </xml>
func GenScanEventTextMsgXml ¶
GenScanEventMsgXml 接收事件推送:生成发送text消息 <xml> <ToUserName><![CDATA[gh_2a871094fffc]]></ToUserName> <FromUserName><![CDATA[oosZs5iF1s4siyAUBu53vNrFEBBY]]></FromUserName> <CreateTime>1684830330</CreateTime> <MsgType><![CDATA[event]]></MsgType> <Content><![CDATA[临时二维码入口进入]]></Content> </xml>
func GetJsapiTicketUrl ¶
func GetOpenidUrl ¶
GetOpenidUrl 根据微信code获取openid
func GetWxUserInfoUrl ¶
GetWxUserInfoUrl 获取微信用户信息(昵称、头像...) -- 页面授权
func GetWxUserInfoUrlByManager ¶
GetWxUserInfoUrlByManager 获取微信用户信息(昵称、头像...) -- 公众号管理
Types ¶
type AccessTokenInfo ¶
type AccessTokenInfo struct { AccessToken string `json:"access_token"` ExpiresIn int64 `json:"expires_in"` }
AccessTokenInfo 请求公众号accessToken的响应 {"access_token":"ACCESS_TOKEN","expires_in":7200}
func ParseWxAccessTokenInfo ¶
func ParseWxAccessTokenInfo(bs []byte) (*AccessTokenInfo, error)
type GetReplyMsgXml ¶
type GetReplyMsgXml struct { ToUserName string `xml:"ToUserName"` FromUserName string `xml:"FromUserName"` CreateTime string `xml:"CreateTime"` MsgType string `xml:"MsgType"` Content string `xml:"Content"` MsgId int64 `xml:"MsgId"` Encrypt string `xml:"Encrypt"` }
<xml> <ToUserName><![CDATA[gh_5b013782f4b4]]></ToUserName> <FromUserName><![CDATA[oLqAc69qMytBNNVYqj-zQ20pV9pc]]></FromUserName> <CreateTime>1690352640</CreateTime> <MsgType><![CDATA[text]]></MsgType> <Content><![CDATA[2]]></Content> <MsgId>24200028314463725</MsgId> <Encrypt><![CDATA[]]></Encrypt> </xml>
type GetScanEventMsgXml ¶
type GetScanEventMsgXml struct { ToUserName string `xml:"ToUserName"` FromUserName string `xml:"FromUserName"` CreateTime string `xml:"CreateTime"` MsgType string `xml:"MsgType"` Event string `xml:"Event"` EventKey string `xml:"EventKey"` Ticket string `xml:"Ticket"` Encrypt string `xml:"Encrypt"` }
type JsapiTicketAuthSign ¶
type JsapiTicketAuthSign struct { JsapiTicket string `json:"jsapiTicket"` Url string `json:"url"` NonceStr string `json:"nonceStr"` Timestamp int64 `json:"timestamp"` Sign string `json:"sign"` }
func JsapiTicketAuth ¶
func JsapiTicketAuth(jsapiTicket, url string) *JsapiTicketAuthSign
type JsapiTicketData ¶
type JsapiTicketData struct { Errcode int `json:"errcode"` Errmsg string `json:"errmsg"` Ticket string `json:"ticket"` ExpiresIn int `json:"expires_in"` }
{ "errcode":0, "errmsg":"ok", "ticket":"bxLdikRXVbTPdHSM05e5u5sUoXNKd8-41ZO3MhKoyN5OfkWITDGgnr2fwJ0m9E8NYzWKVZvdVtaUgWvsdshFKA", "expires_in":7200 }
func GetJsapiTicket ¶
func GetJsapiTicket(accessToken string, timeout ...time.Duration) (*JsapiTicketData, error)
GetJsapiTicket 获取jsapi_ticket
type OpenidInfo ¶
type OpenidInfo struct { AccessToken string `json:"access_token"` ExpiresIn int `json:"expires_in"` RefreshToken string `json:"refresh_token"` Openid string `json:"openid"` Scope string `json:"scope"` }
func ParseOpenidInfo ¶
func ParseOpenidInfo(bs []byte) (*OpenidInfo, error)
ParseOpenidInfo 解析微信响应openid信息 @param b []byte 获取的响应字节 @return *OpenidInfo 微信响应openid信息 @return error 解析错误信息
type QrcodeInfo ¶
type QrcodeInfo struct { Ticket string `json:"ticket"` ExpireSeconds int `json:"expire_seconds"` Url string `json:"url"` }
func GenLimitQrcode ¶
func GenLimitQrcode(accessToken string, info string) (*QrcodeInfo, error)
GenLimitQrcode 永久二维码
type ServerSignatureInfo ¶
type ServerSignatureInfo struct { Signature string `form:"signature"` Timestamp string `form:"timestamp"` Nonce string `form:"nonce"` EchoStr string `form:"echostr"` }
ServerSignatureInfo { "signature":"", "timestamp":"", "nonce":"", "echostr":"" }
type UserInfo ¶
type UserInfo 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"` }
func GetWxUserInfo ¶
func ParseUserInfo ¶
ParseUserInfo 解析微信响应用户信息 @param b []byte 获取的响应字节 @return *OpenidInfo 微信响应用户信息 @return error 解析错误信息
type UserInfoByManager ¶
type UserInfoByManager 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"` Headimgurl string `json:"headimgurl"` SubscribeTime int `json:"subscribe_time"` Remark string `json:"remark"` Groupid int `json:"groupid"` TagidList []any `json:"tagid_list"` SubscribeScene string `json:"subscribe_scene"` QrScene int `json:"qr_scene"` QrSceneStr string `json:"qr_scene_str"` }
func GetWxUserInfoByManager ¶
func GetWxUserInfoByManager(gzhAccessToken, openid string, timeout time.Duration) (*UserInfoByManager, error)
func ParseUserInfoByManager ¶
func ParseUserInfoByManager(b []byte) (*UserInfoByManager, error)
type WxRespErr ¶
WxRespErr 微信响应错误信息 {"errcode":40013,"errmsg":"invalid appid"}
func ParseWxRespErr ¶
ParseWxRespErr 解析微信响应错误信息 @param b []byte 获取的响应字节 @return *WxRespErr 微信响应错误信息 @return error 解析错误信息