wechat_mp

package module
v0.0.0-...-5ec4a0a Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: MIT Imports: 21 Imported by: 0

README

wechat_mini_program

golang GitHub release pkg.go.dev MIT license

🔥 微信小程序 Go 🚀🚀🚀

使用

import "github.com/shenghui0779/wechat_mp"

Documentation

Index

Constants

View Source
const (
	UniformMessageSendURL         = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send"
	SubscribeMessageSendURL       = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send"
	TemplateMessageSendURL        = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send"
	CustomerServiceMessageSendURL = "https://api.weixin.qq.com/cgi-bin/message/custom/send"
	SetTypingURL                  = "https://api.weixin.qq.com/cgi-bin/message/custom/typing"
)

msg

View Source
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

View Source
const (
	MediaUploadURL = "https://api.weixin.qq.com/cgi-bin/media/upload"
	MediaGetURL    = "https://api.weixin.qq.com/cgi-bin/media/get"
)

media

View Source
const (
	PluginManageURL    = "https://api.weixin.qq.com/wxa/plugin"
	PluginDevManageURL = "https://api.weixin.qq.com/wxa/devplugin"
)

plugin

View Source
const (
	ImgSecCheckURL     = "https://api.weixin.qq.com/wxa/img_sec_check"
	MediaCheckAsyncURL = "https://api.weixin.qq.com/wxa/media_check_async"
	MsgSecCheckURL     = "https://api.weixin.qq.com/wxa/msg_sec_check"
)

security

View Source
const (
	AICropURL          = "https://api.weixin.qq.com/cv/img/aicrop"
	ScanQRCodeURL      = "https://api.weixin.qq.com/cv/img/qrcode"
	SuperreSolutionURL = "https://api.weixin.qq.com/cv/img/superresolution"
)

image

View Source
const (
	OCRBankCardURL        = "https://api.weixin.qq.com/cv/ocr/bankcard"
	OCRBusinessLicenseURL = "https://api.weixin.qq.com/cv/ocr/bizlicense"
	OCRDriverLicenseURL   = "https://api.weixin.qq.com/cv/ocr/drivinglicense"
	OCRIDCardURL          = "https://api.weixin.qq.com/cv/ocr/idcard"
	OCRPrintedTextURL     = "https://api.weixin.qq.com/cv/ocr/comm"
	OCRVehicleLicenseURL  = "https://api.weixin.qq.com/cv/ocr/driving"
)

ocr

View Source
const (
	AccessTokenURL = "https://api.weixin.qq.com/cgi-bin/token"
)

cgi-bin

View Source
const (
	Code2SessionURL = "https://api.weixin.qq.com/sns/jscode2session"
)

sns

Variables

View Source
var (
	// PluginApply 向插件开发者发起使用插件的申请
	PluginApply PluginAction = "apply"
	// PluginDevApplyList 获取当前所有插件使用方(供插件开发者调用)
	PluginDevApplyList PluginAction = "dev_apply_list"
	// PluginList 查询已添加的插件
	PluginList = "list"
	// PluginDevAgree 同意申请
	PluginDevAgree = "dev_agree"
	// PluginDevRefuse 拒绝申请
	PluginDevRefuse = "dev_refuse"
	// PluginDevDelete 删除已拒绝的申请者
	PluginDevDelete = "dev_delete"
	// PluginUnbind 删除已添加的插件
	PluginUnbind = "unbind"
)
View Source
var (
	// SecCheckMediaAudio 音频
	SecCheckMediaAudio = 1
	// SecCheckMediaImage 图片
	SecCheckMediaImage = 2
)

Functions

func DecodeBytesToUint32

func DecodeBytesToUint32(b []byte) uint32

DecodeBytesToUint32 从 4 字节的网络字节序里解析出整数 uint32

func EncodeUint32ToBytes

func EncodeUint32ToBytes(i uint32) []byte

EncodeUint32ToBytes 把整数 uint32 格式化成 4 字节的网络字节序

func MarshalWithNoEscapeHTML

func MarshalWithNoEscapeHTML(v interface{}) (string, error)

MarshalWithNoEscapeHTML marshal with no escape HTML

Types

type AESCBCCrypto

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

AESCBCCrypto aes-cbc crypto

func NewAESCBCCrypto

func NewAESCBCCrypto(key, iv []byte) *AESCBCCrypto

NewAESCBCCrypto returns new aes-cbc crypto

func (*AESCBCCrypto) Decrypt

func (c *AESCBCCrypto) Decrypt(cipherText []byte, mode AESPaddingMode) ([]byte, error)

Decrypt aes-cbc decrypt with PKCS#7 padding

func (*AESCBCCrypto) Encrypt

func (c *AESCBCCrypto) Encrypt(plainText []byte, mode AESPaddingMode) ([]byte, error)

Encrypt aes-cbc encrypt with PKCS#7 padding

type AESPaddingMode

type AESPaddingMode string

AESPaddingMode aes padding mode

const (
	// PKCS5 PKCS#5 padding mode
	PKCS5 AESPaddingMode = "PKCS#5"
	// PKCS7 PKCS#7 padding mode
	PKCS7 AESPaddingMode = "PKCS#7"
)

type AICropResult

type AICropResult struct {
	Result  []CropPosition `json:"result"`
	ImgSize ImageSize      `json:"img_size"`
}

AICropResult 图片裁切结果

type AccessToken

type AccessToken struct {
	Token     string `json:"access_token"`
	ExpiresIn int64  `json:"expires_in"`
}

AccessToken 小程序access_token

type Action

type Action interface {
	Body() HTTPBody
	URL() func(accessToken string) string
	Decode() func(resp []byte) error
}

Action defines mp action

func AICrop

func AICrop(filename string, receiver *AICropResult) Action

AICrop 图片智能裁切

func AICropByURL

func AICropByURL(imgURL string, receiver *AICropResult) Action

AICropByURL 图片智能裁切

func ApplyPlugin

func ApplyPlugin(pluginAppID, reason string) Action

ApplyPlugin 向插件开发者发起使用插件的申请

func CreateQRCode

func CreateQRCode(path string, receiver *QRCode, options ...QRCodeOption) Action

CreateQRCode 创建小程序二维码 - 数量有限

func GetMedia

func GetMedia(mediaID string, receiver *Media) Action

GetMedia 获取客服消息内的临时素材

func GetPluginDevApplyList

func GetPluginDevApplyList(page, num int, receiver *[]PluginDevApplyInfo) Action

GetPluginDevApplyList 获取当前所有插件使用方(供插件开发者调用)

func GetPluginList

func GetPluginList(receiver *[]PluginInfo) Action

GetPluginList 查询已添加的插件

func GetQRCode

func GetQRCode(path string, receiver *QRCode, options ...QRCodeOption) Action

GetQRCode 获取小程序二维码 - 数量有限

func GetUnlimitQRCode

func GetUnlimitQRCode(scene string, receiver *QRCode, options ...QRCodeOption) Action

GetUnlimitQRCode 获取小程序二维码 - 数量不限

func ImgSecCheck

func ImgSecCheck(filename string) Action

ImgSecCheck 校验一张图片是否含有违法违规内容

func MediaCheckAsync

func MediaCheckAsync(mediaType SecCheckMediaType, mediaURL string, receiver *MediaCheckAsyncInfo) Action

MediaCheckAsync 异步校验图片/音频是否含有违法违规内容

func MsgSecCheck

func MsgSecCheck(content string) Action

MsgSecCheck 检查一段文本是否含有违法违规内容

func OCRBankCard

func OCRBankCard(mode OCRMode, filename string, receiver *BankCard) Action

OCRBankCard 银行卡识别

func OCRBankCardByURL

func OCRBankCardByURL(mode OCRMode, imgURL string, receiver *BankCard) Action

OCRBankCardByURL 银行卡识别

func OCRBusinessLicense

func OCRBusinessLicense(mode OCRMode, filename string, receiver *BusinessLicense) Action

OCRBusinessLicense 营业执照识别

func OCRBusinessLicenseByURL

func OCRBusinessLicenseByURL(mode OCRMode, imgURL string, receiver *BusinessLicense) Action

OCRBusinessLicenseByURL 营业执照识别

func OCRDriverLicense

func OCRDriverLicense(mode OCRMode, filename string, receiver *DriverLicense) Action

OCRDriverLicense 驾照识别

func OCRDriverLicenseByURL

func OCRDriverLicenseByURL(mode OCRMode, imgURL string, receiver *DriverLicense) Action

OCRDriverLicenseByURL 驾照识别

func OCRIDCardBack

func OCRIDCardBack(mode OCRMode, filename string, receiver *IDCardBack) Action

OCRIDCardBack 身份证背面识别

func OCRIDCardBackByURL

func OCRIDCardBackByURL(mode OCRMode, imgURL string, receiver *IDCardBack) Action

OCRIDCardBackByURL 身份证背面识别

func OCRIDCardFront

func OCRIDCardFront(mode OCRMode, filename string, receiver *IDCardFront) Action

OCRIDCardFront 身份证前面识别

func OCRIDCardFrontByURL

func OCRIDCardFrontByURL(mode OCRMode, imgURL string, receiver *IDCardFront) Action

OCRIDCardFrontByURL 身份证前面识别

func OCRPrintedText

func OCRPrintedText(mode OCRMode, filename string, receiver *PrintedText) Action

OCRPrintedText 通用印刷体识别

func OCRPrintedTextByURL

func OCRPrintedTextByURL(mode OCRMode, imgURL string, receiver *PrintedText) Action

OCRPrintedTextByURL 通用印刷体识别

func OCRVehicleLicense

func OCRVehicleLicense(mode OCRMode, filename string, receiver *VehicleLicense) Action

OCRVehicleLicense 行驶证识别

func OCRVehicleLicenseByURL

func OCRVehicleLicenseByURL(mode OCRMode, imgURL string, receiver *VehicleLicense) Action

OCRVehicleLicenseByURL 行驶证识别

func ScanQRCode

func ScanQRCode(filename string, receiver *QRCodeScanResult) Action

ScanQRCode 条码/二维码识别

func ScanQRCodeByURL

func ScanQRCodeByURL(imgURL string, receiver *QRCodeScanResult) Action

ScanQRCodeByURL 条码/二维码识别

func SendCustomerServiceMessage

func SendCustomerServiceMessage(msg *CustomerServiceMessage) Action

SendCustomerServiceMessage 发送客服消息

func SendSubscribeMessage

func SendSubscribeMessage(msg *SubscribeMessage) Action

SendSubscribeMessage 发送订阅消息

func SendTemplateMessage

func SendTemplateMessage(msg *TemplateMessage) Action

SendTemplateMessage 发送模板消息

func SendUniformMessage

func SendUniformMessage(msg *UniformMessage) Action

Uniform 发送统一服务消息

func SetDevPluginApplyStatus

func SetDevPluginApplyStatus(action PluginAction, appid, reason string) Action

SetDevPluginApplyStatus 修改插件使用申请的状态(供插件开发者调用)

func SetTyping

func SetTyping(msg *TypingMessage) Action

SetTyping 下发当前输入状态,仅支持客服消息

func SuperreSolution

func SuperreSolution(filename string, receiver *SuperreSolutionResult) Action

SuperreSolution 图片高清化

func SuperreSolutionByURL

func SuperreSolutionByURL(imgURL string, receiver *SuperreSolutionResult) Action

SuperreSolutionByURL 图片高清化

func UnbindPlugin

func UnbindPlugin(pluginAppID string) Action

UnbindPlugin 删除已添加的插件

func UploadMedia

func UploadMedia(mediaType MediaType, filename string, receiver *MediaUploadInfo) Action

UploadMedia 上传临时素材到微信服务器

type AuthInfo

type AuthInfo interface {
	AppID() string
}

AuthInfo 小程序授权信息

type AuthSession

type AuthSession struct {
	SessionKey string `json:"session_key"`
	OpenID     string `json:"openid"`
	UnionID    string `json:"unionid"`
}

AuthSession 小程序授权Session

type BankCard

type BankCard struct {
	ID string `json:"id"`
}

BankCard 银行卡

type BusinessLicense

type BusinessLicense struct {
	RegNum              string       `json:"reg_num"`
	Serial              string       `json:"serial"`
	LegalRepresentative string       `json:"legal_representative"`
	EnterpriseName      string       `json:"enterprise_name"`
	TypeOfOrganization  string       `json:"type_of_organization"`
	Address             string       `json:"address"`
	TypeOfEnterprise    string       `json:"type_of_enterprise"`
	BusinessScope       string       `json:"business_scope"`
	RegisteredCapital   string       `json:"registered_capital"`
	PaidInCapital       string       `json:"paid_in_capital"`
	ValidPeriod         string       `json:"valid_period"`
	RegisteredDate      string       `json:"registered_date"`
	CertPosition        CertPosition `json:"cert_position"`
	ImgSize             ImageSize    `json:"img_size"`
}

BusinessLicense 营业执照

type CDATA

type CDATA string

CDATA XML CDATA section which is defined as blocks of text that are not parsed by the parser, but are otherwise recognized as markup.

func (CDATA) MarshalXML

func (c CDATA) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML encodes the receiver as zero or more XML elements.

type CertPosition

type CertPosition struct {
	Pos ImagePosition `json:"pos"`
}

CertPosition 证书位置

type CropPosition

type CropPosition struct {
	CropLeft   int `json:"crop_left"`
	CropTop    int `json:"crop_top"`
	CropRignt  int `json:"crop_rignt"`
	CropBottom int `json:"crop_bottom"`
}

CropPosition 裁切位置

type CustomerServiceMessage

type CustomerServiceMessage struct {
	OpenID      string        // 接收者(用户)的 openid
	MessageType string        // 消息类型:text|image|link|miniprogrampage
	Text        *TextMessage  // 文本消息
	Image       *ImageMessage // 图文链接
	Link        *LinkMessage  // 图文链接
	Page        *PageMessage  // 小程序卡片
}

CustomerServiceMessage 小程序客服消息

type DriverLicense

type DriverLicense struct {
	IDNum        string `json:"id_num"`
	Name         string `json:"name"`
	Sex          string `json:"sex"`
	Address      string `json:"address"`
	BirthDate    string `json:"birth_date"`
	IssueDate    string `json:"issue_date"`
	CarClass     string `json:"car_class"`
	ValidFrom    string `json:"valid_from"`
	ValidTo      string `json:"valid_to"`
	OfficialSeal string `json:"official_seal"`
}

DriverLicense 驾照

type HTTPBody

type HTTPBody interface {
	FieldName() string
	FileName() string
	Bytes() func() ([]byte, error)
}

HTTPBody defines http body

type HTTPClient

type HTTPClient interface {
	Get(reqURL string, options ...HTTPOption) ([]byte, error)
	Post(reqURL string, body []byte, options ...HTTPOption) ([]byte, error)
}

func NewHTTPClient

func NewHTTPClient(tlsCfg ...*tls.Config) HTTPClient

NewHTTPClient returns a new http client

type HTTPOption

type HTTPOption interface {
	// contains filtered or unexported methods
}

HTTPOption configures how we set up the http request

func WithHTTPClose

func WithHTTPClose() HTTPOption

WithHTTPClose specifies close the connection after replying to this request (for servers) or after sending this request and reading its response (for clients).

func WithHTTPCookies

func WithHTTPCookies(cookies ...*http.Cookie) HTTPOption

WithHTTPCookies specifies the cookies to http request.

func WithHTTPHeader

func WithHTTPHeader(key, value string) HTTPOption

WithHTTPHeader specifies the headers to http request.

func WithHTTPTimeout

func WithHTTPTimeout(d time.Duration) HTTPOption

WithHTTPTimeout specifies the timeout to http request.

type IDCardBack

type IDCardBack struct {
	ValidDate string `json:"valid_date"`
}

IDCardBack 身份证背面

type IDCardFront

type IDCardFront struct {
	Name        string `json:"name"`
	ID          string `json:"id"`
	Addr        string `json:"addr"`
	Gender      string `json:"gender"`
	Nationality string `json:"nationality"`
}

IDCardFront 身份证前面

type ImageMessage

type ImageMessage struct {
	MediaID string // 发送的图片的媒体ID,通过 新增素材接口 上传图片文件获得
}

ImageMessage 图片消息

type ImagePosition

type ImagePosition struct {
	LeftTop     Position `json:"left_top"`
	RightTop    Position `json:"right_top"`
	RightBottom Position `json:"right_bottom"`
	LeftBottom  Position `json:"left_bottom"`
}

ImagePosition 图片位置

type ImageSize

type ImageSize struct {
	W int `json:"w"`
	H int `json:"h"`
}

ImageSize 图片尺寸

type LinkMessage

type LinkMessage struct {
	Title       string // 消息标题
	Description string // 图文链接消息
	RedirectURL string // 图文链接消息被点击后跳转的链接
	ThumbURL    string // 图文链接消息的图片链接,支持 JPG、PNG 格式,较好的效果为大图 640 X 320,小图 80 X 80
}

LinkMessage 图文链接

type Media

type Media struct {
	Buffer []byte
}

Media 临时素材

type MediaCheckAsyncInfo

type MediaCheckAsyncInfo struct {
	TraceID string
}

MediaCheckAsyncInfo 任务id,用于匹配异步推送结果

type MediaType

type MediaType string

MediaType 素材类型

var MediaImage MediaType = "image"

MediaImage 图片素材

type MediaUploadInfo

type MediaUploadInfo struct {
	Type      string `json:"type"`
	MediaID   string `json:"media_id"`
	CreatedAt int64  `json:"created_at"`
}

MediaUploadInfo 临时素材上传信息

type MessageBody

type MessageBody map[string]map[string]string

MessageBody 消息内容体

type OATemplateMessage

type OATemplateMessage struct {
	OpenID      string      // 接收者(用户)的 openid
	TemplateID  string      // 模板ID
	RedirectURL string      // 模板跳转链接(海外帐号没有跳转能力)
	MPAppID     string      // 所需跳转到的小程序appid(该小程序appid必须与发模板消息的公众号是绑定关联关系,暂不支持小游戏)
	MPPagePath  string      // 所需跳转到小程序的具体页面路径,支持带参数,(示例index?foo=bar),要求该小程序已发布,暂不支持小游戏
	Data        MessageBody // 模板内容,格式形如:{"key1": {"value": any}, "key2": {"value": any}}
	Color       string      // 模板内容字体颜色,不填默认为黑色
}

OATemplateMessage 公众号模板消息

type OCRMode

type OCRMode string

OCRMode 识别模式

var (
	// OCRPhoto 拍照模式
	OCRPhoto OCRMode = "photo"
	// OCRScan 扫描模式
	OCRScan OCRMode = "scan"
)

type PageMessage

type PageMessage struct {
	Title        string // 消息标题
	Path         string // 小程序的页面路径,跟app.json对齐,支持参数,比如pages/index/index?foo=bar
	ThumbMediaID string // 小程序消息卡片的封面, image 类型的 media_id,通过 新增素材接口 上传图片文件获得,建议大小为 520*416
}

PageMessage 小程序卡片

type PhoneInfo

type PhoneInfo struct {
	PhoneNumber     string    `json:"phoneNumber"`
	PurePhoneNumber string    `json:"purePhoneNumber"`
	CountryCode     string    `json:"countryCode"`
	WaterMark       WaterMark `json:"watermark"`
}

PhoneInfo 用户手机号绑定信息

func (*PhoneInfo) AppID

func (p *PhoneInfo) AppID() string

type PluginAction

type PluginAction string

PluginAction defines for plugin action params

type PluginDevApplyInfo

type PluginDevApplyInfo struct {
	AppID      string `json:"appid"`
	Status     int    `json:"status"`
	Nickname   string `json:"nickname"`
	HeadImgURL string `json:"headimgurl"`
	Categories []X    `json:"categories"`
	CreateTime string `json:"create_time"`
	ApplyURL   string `json:"apply_url"`
	Reason     string `json:"reason"`
}

PluginDevApplyInfo 插件使用方信息

type PluginInfo

type PluginInfo struct {
	AppID      string `json:"appid"`
	Status     int    `json:"status"`
	Nickname   string `json:"nickname"`
	HeadImgURL string `json:"headimgurl"`
}

PluginInfo 插件信息

type Position

type Position struct {
	X int `json:"x"`
	Y int `json:"y"`
}

Position 位置信息

type PostBody

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

PostBody implements http body

func (*PostBody) Bytes

func (b *PostBody) Bytes() func() ([]byte, error)

Bytes returns bytes closure

func (*PostBody) FieldName

func (b *PostBody) FieldName() string

FieldName returns multipart fieldname

func (*PostBody) FileName

func (b *PostBody) FileName() string

FileName returns multipart filename

type PrintedText

type PrintedText struct {
	Items   []PrintedTextItem `json:"items"`
	ImgSize ImageSize         `json:"img_size"`
}

PrintedText 通用印刷体

type PrintedTextItem

type PrintedTextItem struct {
	Text string        `json:"text"`
	Pos  ImagePosition `json:"pos"`
}

PrintedTextItem 通用印刷体内容项

type QRCode

type QRCode struct {
	Buffer []byte
}

QRCode 小程序二维码

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 QRCodeScanData

type QRCodeScanData struct {
	TypeName string        `json:"type_name"`
	Data     string        `json:"data"`
	Pos      ImagePosition `json:"pos"`
}

QRCodeScanData 二维码扫描数据

type QRCodeScanResult

type QRCodeScanResult struct {
	CodeResults []QRCodeScanData `json:"code_results"`
	ImgSize     ImageSize        `json:"img_size"`
}

QRCodeScanResult 二维码扫描结果

type SecCheckMediaType

type SecCheckMediaType int

SecCheckMediaType 检测的素材类型

type SubscribeMessage

type SubscribeMessage struct {
	OpenID     string      // 接收者(用户)的 openid
	TemplateID string      // 所需下发的订阅模板ID
	PagePath   string      // 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转
	Data       MessageBody // 模板内容,格式形如:{"key1": {"value": any}, "key2": {"value": any}}
	MPState    string      // 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版
	Lang       string      // 进入小程序查看”的语言类型,支持zh_CN(简体中文)、en_US(英文)、zh_HK(繁体中文)、zh_TW(繁体中文),默认为zh_CN
}

SubscribeMessage 小程序订阅消息

type SuperreSolutionResult

type SuperreSolutionResult struct {
	MediaID string `json:"media_id"`
}

SuperreSolutionResult 图片高清化结果

type TemplateMessage

type TemplateMessage struct {
	OpenID          string      // 接收者(用户)的 openid
	TemplateID      string      // 所需下发的模板消息的id
	Page            string      // 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转
	FormID          string      // 表单提交场景下,为 submit 事件带上的 formId;支付场景下,为本次支付的 prepay_id
	Data            MessageBody // 模板内容,格式形如:{"key1": {"value": any}, "key2": {"value": any}},不填则下发空模板
	EmphasisKeyword string      // 模板需要放大的关键词,不填则默认无放大,如:"keyword1.DATA"
}

TemplateMessage 小程序模板消息

type TextMessage

type TextMessage struct {
	Content string // 文本消息内容
}

TextMessage 文本消息

type TypingMessage

type TypingMessage struct {
	OpenID  string // 接收者(用户)的 openid
	Command string // 命令:Typing|CancelTyping
}

TypingMessage 输入状态消息

type UniformMessage

type UniformMessage struct {
	OpenID             string             // 接收者(用户)的 openid,可以是小程序的openid,也可以是公众号的openid
	PubAppID           string             // 公众号appid,要求与小程序有绑定且同主体
	MPTemplateMessage  *TemplateMessage   // 小程序模板消息相关的信息,可以参考小程序模板消息接口; 有此节点则优先发送小程序模板消息
	PubTemplateMessage *OATemplateMessage // 公众号模板消息相关的信息,可以参考公众号模板消息接口;有此节点并且没有 MPTemplateMessage 节点时,发送公众号模板消息
}

UniformMessage 统一服务消息

type UserInfo

type UserInfo 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"`
}

UserInfo 用户信息

func (*UserInfo) AppID

func (u *UserInfo) AppID() string

type VehicleLicense

type VehicleLicense struct {
	VehicleType    string `json:"vehicle_type"`
	Owner          string `json:"owner"`
	Addr           string `json:"addr"`
	UseCharacter   string `json:"use_character"`
	Model          string `json:"model"`
	VIN            string `json:"vin"`
	EngineNum      string `json:"engine_num"`
	RegisterDate   string `json:"register_date"`
	IssueDate      string `json:"issue_date"`
	PlateNumB      string `json:"plate_num_b"`
	Record         string `json:"record"`
	PassengersNum  string `json:"passengers_num"`
	TotalQuality   string `json:"total_quality"`
	PrepareQuality string `json:"prepare_quality"`
}

VehicleLicense 行驶证

type WXClient

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

func (*WXClient) Get

func (c *WXClient) Get(reqURL string, options ...HTTPOption) ([]byte, error)

func (*WXClient) Post

func (c *WXClient) Post(reqURL string, body []byte, options ...HTTPOption) ([]byte, error)

type WaterMark

type WaterMark struct {
	Timestamp int64  `json:"timestamp"`
	AppID     string `json:"appid"`
}

WaterMark 水印

type WechatAPI

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

WechatAPI implements mp action

func (*WechatAPI) Body

func (a *WechatAPI) Body() HTTPBody

Body returns http body

func (*WechatAPI) Decode

func (a *WechatAPI) Decode() func(resp []byte) error

Decode returns decode closure

func (*WechatAPI) URL

func (a *WechatAPI) URL() func(accessToken string) string

URL returns url closure

type WechatMP

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

WechatMP 微信小程序

func New

func New(appid, appsecret string) *WechatMP

New returns new wechat mini program

func (*WechatMP) AccessToken

func (w *WechatMP) AccessToken(options ...HTTPOption) (*AccessToken, error)

AccessToken 获取小程序的access_token

func (*WechatMP) Code2Session

func (w *WechatMP) Code2Session(code string, options ...HTTPOption) (*AuthSession, error)

Code2Session 获取小程序授权的session_key

func (*WechatMP) DecryptAuthInfo

func (w *WechatMP) DecryptAuthInfo(sessionKey, iv, encryptedData string, receiver AuthInfo) error

DecryptAuthInfo 解密授权信息

func (*WechatMP) Do

func (w *WechatMP) Do(accessToken string, action Action, options ...HTTPOption) error

Do exec action

type X

type X map[string]interface{}

X is a convenient alias for a map[string]interface{}.

Jump to

Keyboard shortcuts

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