bzwx

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MSGTYPE_SUBSCRIBE   = "subscribe"   // 关注
	MSGTYPE_UNSUBSCRIBE = "unsubscribe" // 取消关注
	MSGTYPE_SCAN        = "SCAN"        // 扫码
	MSGTYPE_TEXT        = "text"        // 用户向公众号发消息
	MSGTYPE_VIEW        = "VIEW"
)

Variables

This section is empty.

Functions

func AccessTokenUrl

func AccessTokenUrl(appid, secret string) string

AccessTokenUrl 获取access_token

func CheckSignature

func CheckSignature(checkSignatureToken, timestamp, nonce string) (string, error)

CheckSignature 验签 @param checkSignatureToken string 微信平台的服务器验签token

func CodeUrl

func CodeUrl(appid, redirectUri string) string

CodeUrl 获取微信用户Code

func GenQrcodeUrl

func GenQrcodeUrl(accessToken string) string

GenQrcodeUrl 生成二维码

func GenReplyNewsMsgXml

func GenReplyNewsMsgXml(memberOpenid, gzhOpenid, title, description, picUrl, url string) string

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

func GenReplyTextMsgXml(memberOpenid, gzhOpenid, content string) string

GenReplyTextMsgXml 被动回复用户消息:生成发送text消息 <xml> <ToUserName><![CDATA[toUser]]></ToUserName> <FromUserName><![CDATA[fromUser]]></FromUserName> <CreateTime>12345678</CreateTime> <MsgType><![CDATA[text]]></MsgType> <Content><![CDATA[你好]]></Content> </xml>

func GenScanEventTextMsgXml

func GenScanEventTextMsgXml(memberOpenid, gzhOpenid, content string) string

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 GetJsapiTicketUrl(accessToken string) string

func GetOpenidUrl

func GetOpenidUrl(appid, secret, code string) string

GetOpenidUrl 根据微信code获取openid

func GetQrcodeImageUrl

func GetQrcodeImageUrl(ticket string) string

GetQrcodeImageUrl 二维码生成后的图片地址

func GetWxUserInfoUrl

func GetWxUserInfoUrl(userAccessToken, openid string) string

GetWxUserInfoUrl 获取微信用户信息(昵称、头像...) -- 页面授权

func GetWxUserInfoUrlByManager

func GetWxUserInfoUrlByManager(gzhAccessToken, openid string) string

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 永久二维码

func GenQrcode

func GenQrcode(accessToken string, expireSeconds int64, info string) (*QrcodeInfo, error)

GenQrcode 临时二维码 info {"scene": {"scene_str": "test"}}

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 GetWxUserInfo(userAccessToken, openid string, timeout time.Duration) (*UserInfo, error)

func ParseUserInfo

func ParseUserInfo(b []byte) (*UserInfo, error)

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

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

WxRespErr 微信响应错误信息 {"errcode":40013,"errmsg":"invalid appid"}

func ParseWxRespErr

func ParseWxRespErr(b []byte) (*WxRespErr, error)

ParseWxRespErr 解析微信响应错误信息 @param b []byte 获取的响应字节 @return *WxRespErr 微信响应错误信息 @return error 解析错误信息

Jump to

Keyboard shortcuts

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