ma

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

微信小程序接口

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddData added in v0.6.0

func AddData(msg *WxMaSubscribeMessage, arr ...*Data)

func CheckSignature added in v0.5.0

func CheckSignature(token, timestamp, nonce, signature string) bool

func CheckUserInfo added in v0.5.0

func CheckUserInfo(sessionKey, rawData, signature string) bool

func CreateJsapiSignature added in v0.6.1

func CreateJsapiSignature(url, appId, ticket string) (*common.WxJsapiSignature, error)

func CreateJsapiSignatureBy added in v0.6.2

func CreateJsapiSignatureBy(appId, secret, url string) (*common.WxJsapiSignature, error)

创建调用jsapi时所需要的签名.

func CreateWxaCodeUnlimited added in v0.6.2

func CreateWxaCodeUnlimited(appId, secret, scene, page string) ([]byte, error)

创建二维码

func GetAccessToken added in v0.6.2

func GetAccessToken(appId, secret string) (*common.AccessToken, error)

获取accessToken

func GetJsapiTicket added in v0.6.2

func GetJsapiTicket(appId, secret string) (*common.Ticket, error)

获取js_ticket

func GetTicket added in v0.6.2

func GetTicket(appId, secret string, t common.TicketType) (*common.Ticket, error)

获取ticket

Types

type BaseCode

type BaseCode struct {
	Width     int           `json:"width"`
	AutoColor bool          `json:"auto_color"`
	IsHyaline bool          `json:"is_hyaline"`
	LineColor CodeLineColor `json:"line_color"`
}

二维码数据

type CategoryData added in v0.6.0

type CategoryData struct {
	Id   uint64 `json:"id"`
	Name string `json:"name"`
}

type CodeLineColor

type CodeLineColor struct {
	R string `json:"r"`
	B string `json:"b"`
	G string `json:"g"`
}

二维码线颜色

func DefaultCodeLineColor

func DefaultCodeLineColor() CodeLineColor

默认白色

type Data added in v0.6.0

type Data struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type JsCode2SessionResult

type JsCode2SessionResult struct {
	common.Err

	SessionKey string `json:"session_key"`
	Openid     string `json:"openid"`
	UnionId    string `json:"unionid"`
}

js_code session_info

func JsCode2SessionInfo added in v0.6.2

func JsCode2SessionInfo(appId, secret, jsCode string) (*JsCode2SessionResult, error)

通过jsCode换取openid和sessionKey

type KfImage added in v0.6.0

type KfImage struct {
	MediaId string `json:"media_id"`
}
type KfLink struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	Url         string `json:"url"`
	ThumbUrl    string `json:"thumb_url"`
}

type KfMaPage added in v0.6.0

type KfMaPage struct {
	Title        string `json:"title"`
	PagePath     string `json:"pagepath"`
	ThumbMediaId string `json:"thumb_media_id"`
}

type KfText added in v0.6.0

type KfText struct {
	Content string `json:"content"`
}

type MiniProgram added in v0.6.0

type MiniProgram struct {
	AppId       string `json:"appid"`
	PagePath    string `json:"page_path"`
	UsePath     bool   `json:"use_path"`
	UsePagePath bool   `json:"use_page_path"`
}

type MiniProgramLang added in v0.6.0

type MiniProgramLang string

小程序语言

const (
	ZhCn MiniProgramLang = "zh_CN"
	EnUs MiniProgramLang = "en_US"
	ZhHk MiniProgramLang = "zh_HK"
	ZhTw MiniProgramLang = "zh_TW"
)

type MiniProgramState added in v0.6.0

type MiniProgramState string

小程序版本

const (
	DEVELOPER MiniProgramState = "developer"
	TRIAL     MiniProgramState = "trial"
	FORMAL    MiniProgramState = "formal"
)

type MsgTemplateInfo added in v0.6.0

type MsgTemplateInfo struct {
	ParameterList []*Parameter `json:"parameter_list"`
}

type Parameter added in v0.6.0

type Parameter struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type PhoneNumberInfo

type PhoneNumberInfo struct {
	PhoneNumber     string    `json:"phone_number"`
	PurePhoneNumber string    `json:"pure_phone_number"`
	CountryCode     string    `json:"country_code"`
	Watermark       Watermark `json:"watermark"`
}

手机号数据

func GetPhoneNoInfo added in v0.5.0

func GetPhoneNoInfo(sessionKey, encryptedData, ivStr string) (*PhoneNumberInfo, error)

解密手机号敏感数据.

type PubTemplateKeyword added in v0.6.0

type PubTemplateKeyword struct {
	Kid     uint64 `json:"kid"`
	Name    string `json:"name"`
	Example string `json:"example"`
	Rule    string `json:"rule"`
}

type RoomInfoBase added in v0.6.1

type RoomInfoBase struct {
	// 直播间名字,最短3个汉字,最长17个汉字,1个汉字相当于2个字符
	Name string `json:"name"`
	/* 背景图,填入mediaID(mediaID获取后,三天内有效);图片mediaID的获取
	   直播间背景图,图片规则:建议像素1080*1920,大小不超过2M
	   请参考以下文档: https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/New_temporary_materials.html;*/
	CoverImg string `json:"coverImg"`
	// 直播计划开始时间(开播时间需要在当前时间的10分钟后 并且 开始时间不能在 6 个月后)
	StartTime uint64 `json:"startTime"`
	// 直播计划结束时间(开播时间和结束时间间隔不得短于30分钟,不得超过24小时)
	EndTime uint64 `json:"endTime"`

	// 主播昵称,最短2个汉字,最长15个汉字,1个汉字相当于2个字符
	AnchorName string `json:"anchorName"`
	// 主播微信号,如果未实名认证,需要先前往“小程序直播”小程序进行实名验证
	// 小程序二维码链接:https://res.wx.qq.com/op_res/BbVNeczA1XudfjVqCVoKgfuWe7e3aUhokktRVOqf_F0IqS6kYR--atCpVNUUC3zr
	AnchorWechat string `json:"anchorWechat"`

	/* 分享图,填入mediaID(mediaID获取后,三天内有效);图片mediaID的获取
	   直播间分享图,图片规则:建议像素800*640,大小不超过1M;
	   请参考以下文档: https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/New_temporary_materials.html;*/
	ShareImg string `json:"shareImg"`

	// 是否关闭点赞 【0:开启,1:关闭】(若关闭,直播开始后不允许开启)
	CloseLike uint64 `json:"closeLike"`
	// 是否关闭货架 【0:开启,1:关闭】(若关闭,直播开始后不允许开启)
	CloseGoods uint64 `json:"closeGoods"`
	// 是否关闭评论 【0:开启,1:关闭】(若关闭,直播开始后不允许开启)
	CloseComment uint64 `json:"closeComment"`
	// 是否关闭回放 【0:开启,1:关闭】默认关闭回放
	CloseReplay uint64 `json:"closeReplay"`
	// 是否关闭分享 【0:开启,1:关闭】默认开启分享(直播开始后不允许修改)
	CloseShare uint64 `json:"closeShare"`
	// 是否关闭客服 【0:开启,1:关闭】 默认关闭客服
	CloseKf uint64 `json:"closeKf"`
	// 是否开启官方收录 【1: 开启,0:关闭】,默认开启收录
	IsFeedsPublic uint64 `json:"isFeedsPublic"`
	/* 购物直播频道封面图,填入mediaID(mediaID获取后,三天内有效);图片mediaID的获取,
	   请参考以下文档: https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/New_temporary_materials.html;
	   购物直播频道封面图,图片规则:建议像素800*800,大小不超过100KB;*/
	FeedsImg string `json:"feedsImg"`
}

直播间基础信息

type TemplateInfo added in v0.6.0

type TemplateInfo struct {
	PriTmplId string `json:"pri_tmpl_id"`
	Title     string `json:"title"`
	Content   string `json:"content"`
	Example   string `json:"example"`
	TypeNum   uint64 `json:"type"`
}

type TemplateItem added in v0.6.0

type TemplateItem struct {
	TypeNum    uint64 `json:"type"`
	Tid        uint64 `json:"tid"`
	CategoryId string `json:"category_id"`
	Title      string `json:"title"`
}

type UserInfo

type UserInfo struct {
	Openid    string    `json:"openid"`
	Nickname  string    `json:"nickname"`
	Gender    string    `json:"gender"`
	Language  string    `json:"language"`
	City      string    `json:"city"`
	Province  string    `json:"province"`
	Country   string    `json:"country"`
	AvatarUrl string    `json:"avatar_url"`
	UnionID   string    `json:"union_id"`
	Watermark Watermark `json:"watermark"`
}

用户数据

func CheckAndGetUserInfo added in v0.5.0

func CheckAndGetUserInfo(sessionKey, rawData, encryptedData, signature, ivStr string) (*UserInfo, error)

func GetUserInfo added in v0.5.0

func GetUserInfo(sessionKey, encryptedData, ivStr string) (*UserInfo, error)

解密用户信息敏感数据.

type Watermark

type Watermark struct {
	Timestamp uint64 `json:"timestamp"`
	AppId     string `json:"appid"`
}

水印数据

type WxLiveCreateRoomRequest added in v0.6.1

type WxLiveCreateRoomRequest struct {
	RoomInfoBase
	/* 主播副号微信号
	   如果未实名认证,需要先前往“小程序直播”小程序进行实名验证
	   小程序二维码链接:https://res.wx.qq.com/op_res/BbVNeczA1XudfjVqCVoKgfuWe7e3aUhokktRVOqf_F0IqS6kYR--atCpVNUUC3zr */
	SubAnchorWechat string `json:"subAnchorWechat"`
	// 直播间类型 【1: 推流,0:手机直播】
	TypeNum uint64 `json:"type"`
	// 横屏、竖屏 【1:横屏,0:竖屏】(横屏:视频宽高比为16:9、4:3、1.85:1 ;竖屏:视频宽高比为9:16、2:3)
	ScreenType uint64 `json:"screenType"`
}

type WxLiveCreateRoomResult added in v0.6.1

type WxLiveCreateRoomResult struct {
	common.Err
	RoomId uint64 `json:"roomId"`
	// "小程序直播" 小程序码, 当主播微信号没有在 “小程序直播“ 小程序实名认证 返回该字段
	QrcodeUrl string `json:"qrcode_url"`
}

type WxLiveEditRoomRequest added in v0.6.1

type WxLiveEditRoomRequest struct {
	RoomInfoBase
	// 直播间id
	Id uint64 `json:"id"`
}

type WxLiveEditRoomResult added in v0.6.1

type WxLiveEditRoomResult struct {
	common.Err
}

type WxMaAddTemplateResult added in v0.6.0

type WxMaAddTemplateResult struct {
	common.Err
	PriTmplId string `json:"pri_tmpl_id"`
}

type WxMaCategoryListResult added in v0.6.0

type WxMaCategoryListResult struct {
	common.Err
	Data []*CategoryData `json:"data"`
}

类目

type WxMaConfig

type WxMaConfig interface {
	common.WxConfig
	common.WxTicket

	GetToken() string
	GetAesKey() string
	GetMsgDataFormat() string
}

func NewWxMaConfig added in v0.5.0

func NewWxMaConfig(appId, secret string) WxMaConfig

type WxMaConfigImpl

type WxMaConfigImpl struct {
	AccessToken *common.AccessToken

	Token         string
	AesKey        string
	MsgDataFormat string
	// contains filtered or unexported fields
}

func (*WxMaConfigImpl) ExpireTicket added in v0.6.1

func (c *WxMaConfigImpl) ExpireTicket(ticketType common.TicketType)

func (*WxMaConfigImpl) GetAccessToken

func (c *WxMaConfigImpl) GetAccessToken() *common.AccessToken

func (*WxMaConfigImpl) GetAesKey

func (c *WxMaConfigImpl) GetAesKey() string

func (*WxMaConfigImpl) GetAppID

func (c *WxMaConfigImpl) GetAppID() string

func (*WxMaConfigImpl) GetMsgDataFormat

func (c *WxMaConfigImpl) GetMsgDataFormat() string

func (*WxMaConfigImpl) GetSecret

func (c *WxMaConfigImpl) GetSecret() string

func (WxMaConfigImpl) GetTicket added in v0.6.1

func (c WxMaConfigImpl) GetTicket(ticketType common.TicketType) *common.Ticket

func (*WxMaConfigImpl) GetToken

func (c *WxMaConfigImpl) GetToken() string

func (WxMaConfigImpl) GetWxTicket added in v0.6.1

func (c WxMaConfigImpl) GetWxTicket() common.WxTicket

func (*WxMaConfigImpl) IsTicketExpired added in v0.6.1

func (c *WxMaConfigImpl) IsTicketExpired(ticketType common.TicketType) bool

func (*WxMaConfigImpl) SetAccessToken

func (c *WxMaConfigImpl) SetAccessToken(at *common.AccessToken)

func (*WxMaConfigImpl) UpdateTicket added in v0.6.1

func (c *WxMaConfigImpl) UpdateTicket(ticketType common.TicketType, ticket *common.Ticket)

type WxMaJsapiService added in v0.6.1

type WxMaJsapiService interface {
	common.WxJsapi
	// 获得卡券api_ticket,不强制刷新api_ticket
	GetCardApiTicket() (*common.Ticket, error)
	// 获得卡券api_ticket
	// 获得时会检查apiToken是否过期,如果过期了,那么就刷新一下,否则就什么都不干
	ForceGetCardApiTicket(forceRefresh bool) (*common.Ticket, error)
}

type WxMaJsapiServiceImpl added in v0.6.1

type WxMaJsapiServiceImpl struct {
	// contains filtered or unexported fields
}

func (*WxMaJsapiServiceImpl) CreateJsapiSignature added in v0.6.1

func (s *WxMaJsapiServiceImpl) CreateJsapiSignature(url string) (*common.WxJsapiSignature, error)

func (*WxMaJsapiServiceImpl) ForceGetCardApiTicket added in v0.6.1

func (s *WxMaJsapiServiceImpl) ForceGetCardApiTicket(forceRefresh bool) (*common.Ticket, error)

func (*WxMaJsapiServiceImpl) ForceGetJsapiTicket added in v0.6.1

func (s *WxMaJsapiServiceImpl) ForceGetJsapiTicket(forceRefresh bool) (*common.Ticket, error)

func (*WxMaJsapiServiceImpl) ForceGetTicket added in v0.6.1

func (s *WxMaJsapiServiceImpl) ForceGetTicket(ticketType common.TicketType, forceRefresh bool) (*common.Ticket, error)

func (*WxMaJsapiServiceImpl) GetCardApiTicket added in v0.6.1

func (s *WxMaJsapiServiceImpl) GetCardApiTicket() (*common.Ticket, error)

func (*WxMaJsapiServiceImpl) GetJsapiTicket added in v0.6.1

func (s *WxMaJsapiServiceImpl) GetJsapiTicket() (*common.Ticket, error)

func (*WxMaJsapiServiceImpl) GetTicket added in v0.6.1

func (s *WxMaJsapiServiceImpl) GetTicket(ticketType common.TicketType) (*common.Ticket, error)

type WxMaKefuMessage added in v0.6.0

type WxMaKefuMessage struct {
	ToUser  string   `json:"touser"`
	MsgType string   `json:"msgtype"`
	Text    *KfText  `json:"text"`
	Image   *KfImage `json:"image"`
	Link    *KfLink  `json:"link"`
	MaPage  KfMaPage `json:"miniprogrampage"`
}

客服消息

type WxMaLiveGoodsResult added in v0.6.1

type WxMaLiveGoodsResult struct {
	GoodsId       uint64 `json:"goods_id"`
	CoverImgUrl   string `json:"cover_img_url"`
	CoverImg      string `json:"cover_img"`
	Name          string `json:"name"`
	Url           string `json:"url"`
	PriceType     uint64 `json:"price_type"`
	AuditStatus   uint64 `json:"audit_status"`
	Price         string `json:"price"`
	Price2        string `json:"price2"`
	ThirdPartyTag string `json:"third_party_tag"`
}

type WxMaLiveReplayResult added in v0.6.1

type WxMaLiveReplayResult struct {
	ExpireTime string `json:"expire_time"`
	CreateTime string `json:"create_time"`
	MediaUrl   string `json:"media_url"`
}

type WxMaLiveResult added in v0.6.0

type WxMaLiveResult struct {
	common.Err

	Total      uint64                     `json:"total"`
	AuditId    uint64                     `json:"auditId"`
	GoodsId    uint64                     `json:"goodsId"`
	Goods      []*WxMaLiveGoodsResult     `json:"goods"`
	RoomInfos  []*WxMaLiveRoomInfosResult `json:"room_info"`
	LiveReplay []*WxMaLiveReplayResult    `json:"live_replay"`
}

直播信息

type WxMaLiveRoomInfosResult added in v0.6.1

type WxMaLiveRoomInfosResult struct {
	Name         string                 `json:"name"`
	RoomId       uint64                 `json:"roomid"`
	CoverImg     string                 `json:"cover_img"`
	ShareImg     string                 `json:"share_img"`
	LiveStatus   string                 `json:"live_status"`
	StartTime    string                 `json:"start_time"`
	EndTime      string                 `json:"end_time"`
	AnchorName   string                 `json:"anchor_name"`
	AnchorWechat string                 `json:"anchor_wechat"`
	AnchorImg    string                 `json:"anchor_img"`
	TypeNum      uint64                 `json:"type"`
	ScreenType   uint64                 `json:"screen_type"`
	CloseLike    uint64                 `json:"close_like"`
	CloseGoods   uint64                 `json:"close_goods"`
	CloseComment uint64                 `json:"close_comment"`
	Goods        []*WxMaLiveGoodsResult `json:"goods"`
}

type WxMaLiveService added in v0.6.0

type WxMaLiveService interface {
	/* 创建直播间
	   调用此接口创建直播间,创建成功后将在直播间列表展示,调用额度:10000次/一天
	   文档地址:https://developers.weixin.qq.com/miniprogram/dev/framework/liveplayer/studio-api.html#1 */
	CreateRoom(*WxLiveCreateRoomRequest) (*WxLiveCreateRoomResult, error)
	/* 编辑直播间
	   调用此接口创建直播间,创建成功后将在直播间列表展示,调用额度:10000次/一天
	   文档地址:https://developers.weixin.qq.com/miniprogram/dev/framework/liveplayer/studio-api.html#6 */
	EditRoom(*WxLiveEditRoomRequest) (*WxLiveEditRoomResult, error)
	// 获取直播房间列表.(分页)
	GetLiveInfos() ([]*WxMaLiveRoomInfosResult, error)
	// 获取所有直播间信息(没有分页直接获取全部)
	GetLiveInfo(start, limit int) (*WxMaLiveResult, error)
	// 获取直播房间回放数据信息.
	GetLiveReplay(action string, roomId uint64, start, limit int) (*WxMaLiveResult, error)
	/* 直播间导入商品
	   调用接口往指定直播间导入已入库的商品
	   调用频率, 调用额度:10000次/一天 */
	AddGoodsToRoom(roomId uint64, goodsIds []uint64) error
}

type WxMaLiveServiceImpl added in v0.6.0

type WxMaLiveServiceImpl struct {
	// contains filtered or unexported fields
}

func (*WxMaLiveServiceImpl) AddGoodsToRoom added in v0.6.0

func (l *WxMaLiveServiceImpl) AddGoodsToRoom(roomId uint64, goodsIds []uint64) error

func (*WxMaLiveServiceImpl) CreateRoom added in v0.6.0

func (*WxMaLiveServiceImpl) EditRoom added in v0.6.1

func (*WxMaLiveServiceImpl) GetLiveInfo added in v0.6.0

func (l *WxMaLiveServiceImpl) GetLiveInfo(start, limit int) (*WxMaLiveResult, error)

func (*WxMaLiveServiceImpl) GetLiveInfos added in v0.6.0

func (l *WxMaLiveServiceImpl) GetLiveInfos() ([]*WxMaLiveRoomInfosResult, error)

func (*WxMaLiveServiceImpl) GetLiveReplay added in v0.6.0

func (l *WxMaLiveServiceImpl) GetLiveReplay(action string, roomId uint64, start, limit int) (*WxMaLiveResult, error)

type WxMaMsgServiceImpl added in v0.6.0

type WxMaMsgServiceImpl struct {
	// contains filtered or unexported fields
}

func (*WxMaMsgServiceImpl) CreateUpdatableMessageActivityId added in v0.6.0

func (m *WxMaMsgServiceImpl) CreateUpdatableMessageActivityId() ([]byte, error)

func (*WxMaMsgServiceImpl) Send added in v0.6.0

func (m *WxMaMsgServiceImpl) Send(url string, msg interface{}) error

func (*WxMaMsgServiceImpl) SendKefuMsg added in v0.6.0

func (m *WxMaMsgServiceImpl) SendKefuMsg(msg *WxMaKefuMessage) error

func (*WxMaMsgServiceImpl) SendSubscribeMsg added in v0.6.0

func (m *WxMaMsgServiceImpl) SendSubscribeMsg(msg *WxMaSubscribeMessage) error

func (*WxMaMsgServiceImpl) SendUniformMsg added in v0.6.0

func (m *WxMaMsgServiceImpl) SendUniformMsg(msg *WxMaUniformMessage) error

func (*WxMaMsgServiceImpl) SetUpdatableMsg added in v0.6.0

func (m *WxMaMsgServiceImpl) SetUpdatableMsg(msg *WxMaUpdatableMsg) error

type WxMaPubTemplateKeywordListResult added in v0.6.0

type WxMaPubTemplateKeywordListResult struct {
	common.Err
	Count uint64                `json:"count"`
	Data  []*PubTemplateKeyword `json:"data"`
}

模板标题下关键词库结果

type WxMaPubTemplateTitleListResult added in v0.6.0

type WxMaPubTemplateTitleListResult struct {
	common.Err
	Count uint64          `json:"count"`
	Data  []*TemplateItem `json:"data"`
}

订阅的公共模板

type WxMaQrCodeServiceImpl

type WxMaQrCodeServiceImpl struct {
	// contains filtered or unexported fields
}

func (WxMaQrCodeServiceImpl) BytesToFile

func (q WxMaQrCodeServiceImpl) BytesToFile(filename string, bytes []byte) error

func (*WxMaQrCodeServiceImpl) CreateQrcode

func (q *WxMaQrCodeServiceImpl) CreateQrcode(path string) ([]byte, error)

func (*WxMaQrCodeServiceImpl) CreateQrcodeBytes

func (q *WxMaQrCodeServiceImpl) CreateQrcodeBytes(path string, width int) (bytes []byte, err error)

func (*WxMaQrCodeServiceImpl) CreateWxaCode

func (q *WxMaQrCodeServiceImpl) CreateWxaCode(path string) ([]byte, error)

func (*WxMaQrCodeServiceImpl) CreateWxaCodeBytes

func (q *WxMaQrCodeServiceImpl) CreateWxaCodeBytes(path string, width int, autoColor bool, lineColor CodeLineColor, isTransparent bool) (bytes []byte, err error)

func (*WxMaQrCodeServiceImpl) CreateWxaCodeUnlimited

func (q *WxMaQrCodeServiceImpl) CreateWxaCodeUnlimited(scene, path string) ([]byte, error)

func (*WxMaQrCodeServiceImpl) CreateWxaCodeUnlimitedBytes

func (q *WxMaQrCodeServiceImpl) CreateWxaCodeUnlimitedBytes(scene, path string, width int, autoColor bool, lineColor CodeLineColor,
	isTransparent bool) (bytes []byte, err error)

type WxMaQrcodeService

type WxMaQrcodeService interface {
	// 获取小程序页面二维码.
	// path 扫码进入的小程序页面路径,最大长度 128 字节,不能为空;对于小游戏,可以只传入 query 部分,来实现传参效果,如:传入 "?foo=bar",即可在 wx.getLaunchOptionsSync 接口中的 query 参数获取到 {foo:"bar"}。
	// width 二维码的宽度,单位 px。最小 280px,最大 1280px
	CreateQrcodeBytes(path string, width int) ([]byte, error)
	// 获取小程序页面二维码.
	// path 扫码进入的小程序页面路径,最大长度 128 字节,不能为空;对于小游戏,可以只传入 query 部分,来实现传参效果,如:传入 "?foo=bar",即可在 wx.getLaunchOptionsSync 接口中的 query 参数获取到 {foo:"bar"}。
	CreateQrcode(path string) ([]byte, error)

	// 接口A: 获取小程序码.
	// path 扫码进入的小程序页面路径,最大长度 128 字节,不能为空;对于小游戏,可以只传入 query 部分,来实现传参效果,如:传入 "?foo=bar",即可在 wx.getLaunchOptionsSync 接口中的 query 参数获取到 {foo:"bar"}。
	// width 二维码的宽度,单位 px。最小 280px,最大 1280px
	// auto_color 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
	// line_color auto_color 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} 十进制表示
	// is_hyaline 是否需要透明底色,为 true 时,生成透明底色的小程序码
	CreateWxaCodeBytes(path string, width int, autoColor bool, lineColor CodeLineColor, isTransparent bool) ([]byte, error)
	// 接口A: 获取小程序码.
	// path 扫码进入的小程序页面路径,最大长度 128 字节,不能为空;对于小游戏,可以只传入 query 部分,来实现传参效果,如:传入 "?foo=bar",即可在 wx.getLaunchOptionsSync 接口中的 query 参数获取到 {foo:"bar"}。
	CreateWxaCode(path string) ([]byte, error)

	// 接口B: 获取小程序码(永久有效、数量暂无限制).
	// scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)
	// page 必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, 根路径前不要填加 /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面
	// width 二维码的宽度,单位 px,最小 280px,最大 1280px
	// auto_color 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调,默认 false
	// line_color auto_color 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} 十进制表示
	// is_hyaline 是否需要透明底色,为 true 时,生成透明底色的小程序
	CreateWxaCodeUnlimitedBytes(scene, page string, width int, autoColor bool, lineColor CodeLineColor, isTransparent bool) ([]byte, error)
	// 接口B: 获取小程序码(永久有效、数量暂无限制).
	// scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)
	// page 必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, 根路径前不要填加 /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面
	CreateWxaCodeUnlimited(scene, page string) ([]byte, error)
}

type WxMaService

type WxMaService interface {
	common.WxService
	// 获取配置
	GetWxMaConfig() WxMaConfig
	// 设置配置
	SetWxMaConfig(WxMaConfig)

	// jsCode换取openid
	JsCode2SessionInfo(jsCode string) (*JsCode2SessionResult, error)
	// 验证消息的确来自微信服务器
	// 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421135319&token=&lang=zh_CN
	CheckSignature(timestamp, nonce, signature string) bool
	/* 用户支付完成后,获取该用户的UnionId,无需用户授权。本接口支持第三方平台代理查询。
	   注意:调用前需要用户完成支付,且在支付后的五分钟内有效。
	   文档地址:https://developers.weixin.qq.com/miniprogram/dev/api/getPaidUnionId.html */
	GetPaidUnionId(openid, transactionId, mchId, outTradeNo string) (*WxMaUnionIdResult, error)

	// 获取用户接口
	GetWxMaUserService() WxMaUserService
	// 设置(用户自定义的)用户接口
	SetWxMaUserService(WxMaUserService)
	// 获取二维码接口
	GetWxMaQrcodeService() WxMaQrcodeService
	// 获取订阅接口
	GetWxMaSubscribeService() WxMaSubscribeService
	// 获取分享接口
	GetWxMaShareService() WxMaShareService
	// 获取消息接口
	GetWxMaMessageService() WxMaMsgService
	// 获取设置jsapi接口
	GetWxMaJsapiService() WxMaJsapiService
	// 设置(用户自定义的)二维码接口
	SetWxMaQrcodeService(WxMaQrcodeService)
	// 设置(用户自定义的)订阅接口
	SetWxMaSubscribeService(WxMaSubscribeService)
	// 设置(用户自定义的)分享接口
	SetWxMaShareService(WxMaShareService)
	// 设置(用户自定义的)消息接口
	SetWxMaMsgService(WxMaMsgService)
	// 设置jsapi接口
	SetWxMaJsapiService(WxMaJsapiService)
}

func NewWxMaService

func NewWxMaService(config WxMaConfig) WxMaService

func NewWxMaServiceBy added in v0.5.0

func NewWxMaServiceBy(appId, secret string) WxMaService

type WxMaServiceImpl

type WxMaServiceImpl struct {
	common.WxServiceImpl
	// contains filtered or unexported fields
}

func (*WxMaServiceImpl) CheckSignature

func (s *WxMaServiceImpl) CheckSignature(timestamp, nonce, signature string) bool

func (*WxMaServiceImpl) GetPaidUnionId added in v0.6.0

func (s *WxMaServiceImpl) GetPaidUnionId(openid, transactionId, mchId, outTradeNo string) (*WxMaUnionIdResult, error)

func (*WxMaServiceImpl) GetWxMaConfig

func (s *WxMaServiceImpl) GetWxMaConfig() WxMaConfig

func (*WxMaServiceImpl) GetWxMaJsapiService added in v0.6.1

func (s *WxMaServiceImpl) GetWxMaJsapiService() WxMaJsapiService

func (*WxMaServiceImpl) GetWxMaMessageService added in v0.6.0

func (s *WxMaServiceImpl) GetWxMaMessageService() WxMaMsgService

func (*WxMaServiceImpl) GetWxMaQrcodeService

func (s *WxMaServiceImpl) GetWxMaQrcodeService() WxMaQrcodeService

func (*WxMaServiceImpl) GetWxMaShareService added in v0.6.0

func (s *WxMaServiceImpl) GetWxMaShareService() WxMaShareService

func (*WxMaServiceImpl) GetWxMaSubscribeService added in v0.6.0

func (s *WxMaServiceImpl) GetWxMaSubscribeService() WxMaSubscribeService

func (*WxMaServiceImpl) GetWxMaUserService

func (s *WxMaServiceImpl) GetWxMaUserService() WxMaUserService

func (*WxMaServiceImpl) JsCode2SessionInfo

func (s *WxMaServiceImpl) JsCode2SessionInfo(jsCode string) (*JsCode2SessionResult, error)

func (*WxMaServiceImpl) SetWxMaConfig

func (s *WxMaServiceImpl) SetWxMaConfig(config WxMaConfig)

func (*WxMaServiceImpl) SetWxMaJsapiService added in v0.6.1

func (s *WxMaServiceImpl) SetWxMaJsapiService(jsapiService WxMaJsapiService)

func (*WxMaServiceImpl) SetWxMaMsgService added in v0.6.0

func (s *WxMaServiceImpl) SetWxMaMsgService(msgService WxMaMsgService)

func (*WxMaServiceImpl) SetWxMaQrcodeService added in v0.5.0

func (s *WxMaServiceImpl) SetWxMaQrcodeService(qrcodeService WxMaQrcodeService)

func (*WxMaServiceImpl) SetWxMaShareService added in v0.6.0

func (s *WxMaServiceImpl) SetWxMaShareService(shareService WxMaShareService)

func (*WxMaServiceImpl) SetWxMaSubscribeService added in v0.6.0

func (s *WxMaServiceImpl) SetWxMaSubscribeService(subscribeService WxMaSubscribeService)

func (*WxMaServiceImpl) SetWxMaUserService added in v0.5.0

func (s *WxMaServiceImpl) SetWxMaUserService(userService WxMaUserService)

type WxMaShareInfo added in v0.6.0

type WxMaShareInfo struct {
	common.Err

	OpenGId string `json:"open_g_id"`
}

分享的敏感信息

func GetShareInfo added in v0.6.0

func GetShareInfo(sessionKey, encryptedData, ivStr string) (*WxMaShareInfo, error)

解密分享敏感数据.

type WxMaShareService added in v0.6.0

type WxMaShareService interface {
	// 解密分享敏感数据.
	GetShareInfo(sessionKey, encryptedData, ivStr string) (*WxMaShareInfo, error)
}

type WxMaShareServiceImpl added in v0.6.0

type WxMaShareServiceImpl struct {
	// contains filtered or unexported fields
}

func (*WxMaShareServiceImpl) GetShareInfo added in v0.6.0

func (s *WxMaShareServiceImpl) GetShareInfo(sessionKey, encryptedData, ivStr string) (*WxMaShareInfo, error)

type WxMaSubscribeMessage added in v0.6.0

type WxMaSubscribeMessage struct {
	ToUser           string           `json:"to_user"`
	TemplateId       string           `json:"template_id"`
	Page             string           `json:"page"`
	Data             []*Data          `json:"data"`
	MiniProgramState MiniProgramState `json:"miniprogram_state"`
	Lang             MiniProgramLang  `json:"lang"`
}

订阅消息

func NewWxMaSubscribeMessage added in v0.6.0

func NewWxMaSubscribeMessage(toUser, templateId, page string, arr ...*Data) *WxMaSubscribeMessage

func (*WxMaSubscribeMessage) AddData added in v0.6.0

func (m *WxMaSubscribeMessage) AddData(data *Data) *WxMaSubscribeMessage

type WxMaSubscribeService added in v0.6.0

type WxMaSubscribeService interface {
	/* 获取帐号所属类目下的公共模板标题
	   详情请见: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.getPubTemplateTitleList.html */
	GetPubTemplateTitleList(ids []string, start, limit int) (*WxMaPubTemplateTitleListResult, error)
	/* 获取模板库某个模板标题下关键词库
	   详情请见: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.getPubTemplateKeyWordsById.html */
	GetPubTemplateKeyWordsById(id string) (*WxMaPubTemplateKeywordListResult, error)
	/* 获取当前帐号下的个人模板列表
	   详情请见: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.getTemplateList.html */
	GetTemplateList() (*WxMaTemplateListResult, error)
	/* 组合模板并添加至帐号下的个人模板库
	   详情请见: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.addTemplate.html */
	AddTemplate(id, sceneDesc string, keywordIds []string) (*WxMaAddTemplateResult, error)
	/* 删除帐号下的某个模板
	   详情请见: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.deleteTemplate.html */
	DelTemplate(templateId string) error
	/* 获取小程序账号的类目
	   详情请见: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.getCategory.html */
	GetCategory() (*WxMaCategoryListResult, error)
	/* 发送订阅消息
	   详情请见: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.send.html */
	SendMsg(msg *WxMaSubscribeMessage) error
}

type WxMaSubscribeServiceImpl added in v0.6.0

type WxMaSubscribeServiceImpl struct {
	// contains filtered or unexported fields
}

func (*WxMaSubscribeServiceImpl) AddTemplate added in v0.6.0

func (i *WxMaSubscribeServiceImpl) AddTemplate(id, sceneDesc string, keywordIds []string) (*WxMaAddTemplateResult, error)

func (*WxMaSubscribeServiceImpl) DelTemplate added in v0.6.0

func (i *WxMaSubscribeServiceImpl) DelTemplate(templateId string) error

func (*WxMaSubscribeServiceImpl) GetCategory added in v0.6.0

func (*WxMaSubscribeServiceImpl) GetPubTemplateKeyWordsById added in v0.6.0

func (i *WxMaSubscribeServiceImpl) GetPubTemplateKeyWordsById(id string) (*WxMaPubTemplateKeywordListResult, error)

func (*WxMaSubscribeServiceImpl) GetPubTemplateTitleList added in v0.6.0

func (i *WxMaSubscribeServiceImpl) GetPubTemplateTitleList(ids []string, start, limit int) (*WxMaPubTemplateTitleListResult, error)

func (*WxMaSubscribeServiceImpl) GetTemplateList added in v0.6.0

func (i *WxMaSubscribeServiceImpl) GetTemplateList() (*WxMaTemplateListResult, error)

func (*WxMaSubscribeServiceImpl) SendMsg added in v0.6.0

type WxMaTemplateData added in v0.6.0

type WxMaTemplateData struct {
	Name  string `json:"name"`
	Value string `json:"value"`
	Color string `json:"color"`
}

type WxMaTemplateListResult added in v0.6.0

type WxMaTemplateListResult struct {
	common.Err
	Data []*TemplateInfo `json:"data"`
}

个人模板结果

type WxMaUniformMessage added in v0.6.0

type WxMaUniformMessage struct {
	IsMpTemplateMsg bool                `json:"is_mp_template_msg"`
	ToUser          string              `json:"to_user"`
	AppId           string              `json:"appid"`
	TemplateId      string              `json:"template_id"`
	Url             string              `json:"url"`
	Page            string              `json:"page"`
	FormId          string              `json:"form_id"`
	MiniProgram     MiniProgram         `json:"mini_program"`
	Data            []*WxMaTemplateData `json:"data"`
	EmphasisKeyword string              `json:"emphasis_keyword"`
}

下发的服务消息

type WxMaUnionIdResult added in v0.6.0

type WxMaUnionIdResult struct {
	common.Err

	UnionId string `json:"unionid"`
}

用户的UnionId

type WxMaUpdatableMsg added in v0.6.0

type WxMaUpdatableMsg struct {
	ActivityId   string           `json:"activity_id"`
	TargetState  uint64           `json:"target_state"`
	TemplateInfo *MsgTemplateInfo `json:"template_info"`
}

上报信息

type WxMaUserService

type WxMaUserService interface {
	// jsCode换取openid
	GetSessionInfo(jsCode string) (*JsCode2SessionResult, error)
	// 解密用户敏感数据
	GetUserInfo(sessionKey, encryptedData, ivStr string) (*UserInfo, error)
	// 解密用户手机号信息.
	GetPhoneNoInfo(sessionKey, encryptedData, ivStr string) (*PhoneNumberInfo, error)
	// 验证用户信息完整性
	CheckUserInfo(sessionKey, rawData, signature string) bool
	/* 上报用户数据后台接口.
	   小游戏可以通过本接口上报key-value数据到用户的CloudStorage。
	   文档参考https://developers.weixin.qq.com/minigame/dev/document/open-api/data/setUserStorage.html */
	SetUserStorage(kvMap map[string]string, sessionKey, openid string) error
}

type WxMaUserServiceImpl

type WxMaUserServiceImpl struct {
	// contains filtered or unexported fields
}

func (*WxMaUserServiceImpl) CheckUserInfo added in v0.5.0

func (u *WxMaUserServiceImpl) CheckUserInfo(sessionKey, rawData, signature string) bool

func (*WxMaUserServiceImpl) GetPhoneNoInfo

func (u *WxMaUserServiceImpl) GetPhoneNoInfo(sessionKey, encryptedData, ivStr string) (*PhoneNumberInfo, error)

func (*WxMaUserServiceImpl) GetSessionInfo

func (u *WxMaUserServiceImpl) GetSessionInfo(jsCode string) (*JsCode2SessionResult, error)

func (*WxMaUserServiceImpl) GetUserInfo

func (u *WxMaUserServiceImpl) GetUserInfo(sessionKey, encryptedData, ivStr string) (*UserInfo, error)

func (*WxMaUserServiceImpl) SetUserStorage added in v0.6.1

func (u *WxMaUserServiceImpl) SetUserStorage(kvMap map[string]string, sessionKey, openid string) error

type WxaCode

type WxaCode struct {
	BaseCode
	Path string `json:"path"`
}

二维码数据

type WxaCodeUnlimited

type WxaCodeUnlimited struct {
	BaseCode
	Scene string `json:"scene"`
	Page  string `json:"page"`
}

二维码数据

Jump to

Keyboard shortcuts

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