Documentation
¶
Index ¶
- Constants
- func MarshalWithNoEscapeHTML(v interface{}) (string, error)
- type AccessToken
- type AuthSession
- type BizDataCrypt
- type CgiBin
- type CustomerServiceMsg
- type ImageMsg
- type LinkMsg
- type Media
- type Message
- func (m *Message) CustomerService(msg *CustomerServiceMsg, accessToken string) error
- func (m *Message) SetTyping(msg *TypingMsg, accessToken string) error
- func (m *Message) Subscribe(msg *SubscribeMsg, accessToken string) error
- func (m *Message) Template(msg *TplMsg, accessToken string) error
- func (m *Message) Uniform(msg *UniformMsg, accessToken string) error
- type MsgBody
- type PageMsg
- type PhoneData
- type QRCode
- type QRCodeOption
- type Sns
- type SubscribeMsg
- type TextMsg
- type TplMsg
- type TypingMsg
- type UniformMsg
- type UploadData
- type UserData
- type WXMP
- func (wx *WXMP) BizDataCrypt(encryptedData, sessionKey, iv string) *BizDataCrypt
- func (wx *WXMP) CgiBin(options ...utils.HTTPRequestOption) *CgiBin
- func (wx *WXMP) Message(options ...utils.HTTPRequestOption) *Message
- func (wx *WXMP) QRCode(options ...utils.HTTPRequestOption) *QRCode
- func (wx *WXMP) Sns(options ...utils.HTTPRequestOption) *Sns
- type WaterMark
Constants ¶
const ( UniformMsgSendURL = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send" SubscribeMsgSendURL = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send" TplMsgSendURL = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send" CustomerServiceMsgSendURL = "https://api.weixin.qq.com/cgi-bin/message/custom/send" SetTypingURL = "https://api.weixin.qq.com/cgi-bin/message/custom/typing" )
msg
const ( QRCodeCreateURL = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode" QRCodeGetURL = "https://api.weixin.qq.com/wxa/getwxacode" QRCodeGetUnlimitURL = "https://api.weixin.qq.com/wxa/getwxacodeunlimit" )
qrcode
const ( MediaUploadURL = "https://api.weixin.qq.com/cgi-bin/media/upload" MediaGetURL = "https://api.weixin.qq.com/cgi-bin/media/get" )
media
const (
AccessTokenURL = "https://api.weixin.qq.com/cgi-bin/token"
)
cgi-bin
const (
Code2SessionURL = "https://api.weixin.qq.com/sns/jscode2session"
)
sns
Variables ¶
This section is empty.
Functions ¶
func MarshalWithNoEscapeHTML ¶
MarshalWithNoEscapeHTML marshal with no escape HTML
Types ¶
type AccessToken ¶
AccessToken wxmp access_token
type AuthSession ¶
type AuthSession struct { SessionKey string `json:"session_key"` OpenID string `json:"openid"` UnionID string `json:"unionid"` }
AuthSession 小程序授权Session
type BizDataCrypt ¶
type BizDataCrypt struct {
// contains filtered or unexported fields
}
BizDataCrypt 小程序数据解析
func (*BizDataCrypt) GetPhoneData ¶
func (b *BizDataCrypt) GetPhoneData() (*PhoneData, error)
GetPhoneData 获取用户手机号绑定数据(需先解密)
func (*BizDataCrypt) GetUserData ¶
func (b *BizDataCrypt) GetUserData() (*UserData, error)
GetUserData 获取用户数据(需先解密)
type CgiBin ¶
type CgiBin struct {
// contains filtered or unexported fields
}
CgiBin cgi-bin
func (*CgiBin) GetAccessToken ¶
func (p *CgiBin) GetAccessToken() (*AccessToken, error)
GetAccessToken returns access_token
type CustomerServiceMsg ¶ added in v1.1.0
type CustomerServiceMsg struct { OpenID string // 接收者(用户)的 openid MsgType string // 消息类型:text|image|link|miniprogrampage Text *TextMsg // 文本消息 Image *ImageMsg // 图文链接 Link *LinkMsg // 图文链接 Page *PageMsg // 小程序卡片 }
CustomerServiceMsg 小程序客服消息
type ImageMsg ¶ added in v1.1.0
type ImageMsg struct {
MediaID string // 发送的图片的媒体ID,通过 新增素材接口 上传图片文件获得
}
ImageMsg 图片消息
type LinkMsg ¶ added in v1.1.0
type LinkMsg struct { Title string // 消息标题 Description string // 图文链接消息 RedirectURL string // 图文链接消息被点击后跳转的链接 ThumbURL string // 图文链接消息的图片链接,支持 JPG、PNG 格式,较好的效果为大图 640 X 320,小图 80 X 80 }
LinkMsg 图文链接
type Media ¶ added in v1.1.0
type Media struct {
// contains filtered or unexported fields
}
Media 媒体
type Message ¶ added in v1.1.0
type Message struct {
// contains filtered or unexported fields
}
Message 小程序消息
func (*Message) CustomerService ¶ added in v1.1.0
func (m *Message) CustomerService(msg *CustomerServiceMsg, accessToken string) error
CustomerService 发送客服消息
func (*Message) Subscribe ¶ added in v1.1.0
func (m *Message) Subscribe(msg *SubscribeMsg, accessToken string) error
Subscribe 发送订阅消息
type PageMsg ¶ added in v1.1.0
type PageMsg struct { Title string // 消息标题 Path string // 小程序的页面路径,跟app.json对齐,支持参数,比如pages/index/index?foo=bar ThumbMediaID string // 小程序消息卡片的封面, image 类型的 media_id,通过 新增素材接口 上传图片文件获得,建议大小为 520*416 }
PageMsg 小程序卡片
type PhoneData ¶
type PhoneData struct { PhoneNumber string `json:"phoneNumber"` PurePhoneNumber string `json:"purePhoneNumber"` CountryCode string `json:"countryCode"` WaterMark *WaterMark `json:"watermark"` }
PhoneData 用户手机号绑定数据
type QRCode ¶
type QRCode struct {
// contains filtered or unexported fields
}
QRCode 小程序二维码
func (*QRCode) Create ¶
func (q *QRCode) Create(accessToken, path string, options ...QRCodeOption) ([]byte, error)
Create 数量有限
func (*QRCode) Get ¶
func (q *QRCode) Get(accessToken, path string, options ...QRCodeOption) ([]byte, error)
Get 数量有限
func (*QRCode) GetUnlimit ¶
func (q *QRCode) GetUnlimit(accessToken, scene string, options ...QRCodeOption) ([]byte, error)
GetUnlimit 数量不限
type QRCodeOption ¶
type QRCodeOption interface {
// contains filtered or unexported methods
}
QRCodeOption configures how we set up the wxa_qrcode
func WithQRCodeAutoColor ¶
func WithQRCodeAutoColor(b bool) QRCodeOption
WithQRCodeAutoColor specifies the `auto_color` to wxa_qrcode.
func WithQRCodeIsHyaline ¶
func WithQRCodeIsHyaline(b bool) QRCodeOption
WithQRCodeIsHyaline specifies the `is_hyaline` to wxa_qrcode.
func WithQRCodeLineColor ¶
func WithQRCodeLineColor(m map[string]int) QRCodeOption
WithQRCodeLineColor specifies the `line_color` to wxa_qrcode.
func WithQRCodePage ¶
func WithQRCodePage(s string) QRCodeOption
WithQRCodePage specifies the `page` to wxa_qrcode.
func WithQRCodeWidth ¶
func WithQRCodeWidth(w int) QRCodeOption
WithQRCodeWidth specifies the `width` to wxa_qrcode.
type Sns ¶
type Sns struct {
// contains filtered or unexported fields
}
Sns sns
func (*Sns) Code2Session ¶
func (s *Sns) Code2Session(code string) (*AuthSession, error)
Code2Session 获取小程序授权SessionKey
type SubscribeMsg ¶ added in v1.1.0
type SubscribeMsg struct { OpenID string // 接收者(用户)的 openid TplID string // 所需下发的订阅模板ID PagePath string // 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转 Data MsgBody // 模板内容,格式形如:{"key1": {"value": any}, "key2": {"value": any}} MPState string // 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版 Lang string // 进入小程序查看”的语言类型,支持zh_CN(简体中文)、en_US(英文)、zh_HK(繁体中文)、zh_TW(繁体中文),默认为zh_CN }
SubscribeMsg 小程序订阅消息
type TplMsg ¶ added in v1.1.0
type TplMsg struct { OpenID string // 接收者(用户)的 openid TplID string // 所需下发的模板消息的id Page string // 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转 FormID string // 表单提交场景下,为 submit 事件带上的 formId;支付场景下,为本次支付的 prepay_id Data MsgBody // 模板内容,格式形如:{"key1": {"value": any}, "key2": {"value": any}},不填则下发空模板 EmphasisKeyword string // 模板需要放大的关键词,不填则默认无放大,如:"keyword1.DATA" }
TplMsg 小程序模板消息
type UniformMsg ¶ added in v1.1.0
type UniformMsg struct { OpenID string // 接收者(用户)的 openid,可以是小程序的openid,也可以是公众号的openid PubAppID string // 公众号appid,要求与小程序有绑定且同主体 MPTplMsg *TplMsg // 小程序模板消息相关的信息,可以参考小程序模板消息接口; 有此节点则优先发送小程序模板消息 PubTplMsg *pub.TplMsg // 公众号模板消息相关的信息,可以参考公众号模板消息接口;有此节点并且没有 MPTplMsg 节点时,发送公众号模板消息 }
UniformMsg 统一服务消息
type UploadData ¶ added in v1.1.0
type UploadData struct { MediaType string // 文件类型,合法值:image FormData url.Values // form-data 中媒体文件标识,有filename、filelength、content-type等信息 }
UploadData 媒体上传数据
type UserData ¶
type UserData struct { OpenID string `json:"openId"` Language string `json:"language"` City string `json:"city"` Province string `json:"province"` AvatarURL string `json:"avatarUrl"` NickName string `json:"nickName"` Gender int `json:"gender"` Country string `json:"country"` UnionID string `json:"unionId"` WaterMark *WaterMark `json:"watermark"` }
UserData 用户数据
type WXMP ¶
type WXMP struct { AppID string AppSecret string Client *utils.HTTPClient }
WXMP 微信小程序
func (*WXMP) BizDataCrypt ¶
func (wx *WXMP) BizDataCrypt(encryptedData, sessionKey, iv string) *BizDataCrypt
BizDataCrypt returns new bizdatacrypt
func (*WXMP) CgiBin ¶
func (wx *WXMP) CgiBin(options ...utils.HTTPRequestOption) *CgiBin
CgiBin returns new cgi-bin
func (*WXMP) Message ¶ added in v1.1.0
func (wx *WXMP) Message(options ...utils.HTTPRequestOption) *Message
Message returns new message