oa

package
v1.1.13 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: MIT Imports: 14 Imported by: 0

README

微信公众号(Official Accounts)

import (
    "github.com/shenghui0779/gochat"
    "github.com/shenghui0779/gochat/oa"
)
初始化公众号实例
wxoa := gochat.NewOA(appid, appsecret)

// 如果启用了服务器配置,需要设置配置项
wxoa.SetServerConfig(token, encodingAESKey)

// 如果需要消息回复,需要设置原始ID(开发者微信号)
wxoa.SetOriginID(originID)
网页授权
// 生成网页授权URL(请使用 URLEncode 对 redirectURL 进行处理)
wxoa.AuthURL(scope, redirect_url)

// 获取网页授权AccessToken
wxoa.Code2AuthToken(ctx, code)

// 刷新网页授权AccessToken
wxoa.RefreshAuthToken(ctx, refresh_token)

// 检验授权凭证(access_token)是否有效
wxoa.Do(ctx, access_token, oa.CheckAuthToken(openid))

// 获取授权用户信息(注意:使用网页授权的access_token)
wxoa.Do(ctx, access_token, oa.GetAuthUser(dest, openid))

// 获取普通AccessToken
wxoa.AccessToken(ctx)
自定义菜单
// 创建自定义菜单
wxoa.Do(ctx, access_token, oa.CreateMenu(buttons...))

// 创建个性化菜单
wxoa.Do(ctx, access_token, oa.CreateConditionalMenu(match_rule, buttons...))

// 查询自定义菜单
wxoa.Do(ctx, access_token, oa.GetMenu(dest))

// 删除自定义菜单
wxoa.Do(ctx, access_token, oa.DeleteMenu())

// 删除个性化菜单
wxoa.Do(ctx, access_token, oa.DeleteConditionalMenu(menu_id))
用户管理
// 获取关注用户信息
wxoa.Do(ctx, access_token, oa.GetSubscriberInfo(dest, openid))

// 批量关注用户信息
wxoa.Do(ctx, access_token, oa.BatchGetSubscribers(dest, openids...)

// 获取关注用户列表
wxoa.Do(ctx, access_token, oa.GetSubscriberList(dest, next_openid)

// 获取用户黑名单列表
wxoa.Do(ctx, access_token, oa.GetBlackList(dest, begin_openid)

// 拉黑用户
wxoa.Do(ctx, access_token, oa.BlackSubscribers(openids...))

// 取消拉黑用户
wxoa.Do(ctx, access_token, oa.UnBlackSubscribers(openids...))

// 设置用户备注名(该接口暂时开放给微信认证的服务号)
wxoa.Do(ctx, access_token, oa.SetUserRemark(openid, remark))
消息
// 获取模板列表
wxoa.Do(ctx, access_token, oa.GetTemplateList(dest))

// 删除模板
wxoa.Do(ctx, access_token, oa.DeleteTemplate(template_id))

// 发送模板消息
wxoa.Do(ctx, access_token, oa.SendTemplateMessage(openid, msg))

// 发送订阅消息
wxoa.Do(ctx, access_token, oa.SendSubscribeMessage(openid, scene, title, msg))
推广
// 创建临时二维码(expireSeconds:二维码有效时间,最大不超过2592000秒(即30天),不填,则默认有效期为30秒。)
wxoa.Do(ctx, access_token, oa.CreateTempQRCode(dest, sence_id, expire_seconds...))

// 创建永久二维码(expireSeconds:二维码有效时间,最大不超过2592000秒(即30天),不填,则默认有效期为30秒。)
wxoa.Do(ctx, access_token, oa.CreatePermQRCode(dest, sence_id, expire_seconds...))

// 长链接转短链接(长链接支持http://、https://、weixin://wxpay格式的url)
wxoa.Do(ctx, access_token, oa.Long2ShortURL(dest, longURL))
素材管理
// 上传临时素材
wxoa.Do(ctx, access_token, oa.UploadMedia(dest, media_type, filename))

// 新增永久图文素材(公众号的素材库保存总数量有上限:图文消息素材、图片素材上限为100000,其他类型为1000)
wxoa.Do(ctx, access_token, oa.AddNews(dest, articles...))

// 上传图文消息内的图片(不受公众号的素材库中图片数量的100000个的限制,图片仅支持jpg/png格式,大小必须在1MB以下)
wxoa.Do(ctx, access_token, oa.UploadNewsImage(dest, filename))

// 新增其他类型永久素材(支持图片、音频、缩略图)
wxoa.Do(ctx, access_token, oa.AddMaterial(dest, media_type, filename))

// 上传视频永久素材
wxoa.Do(ctx, access_token, oa.UploadVideo(dest, filename, title, introduction))

// 删除永久素材
wxoa.Do(ctx, access_token, oa.DeleteMaterial(media_id))
图像处理
// 图片智能裁切
wxoa.Do(ctx, access_token, oa.AICrop(dest, filename))
wxoa.Do(ctx, access_token, oa.AICropByURL(dest, imgURL))

// 条码/二维码识别
wxoa.Do(ctx, access_token, oa.ScanQRCode(dest, filename))
wxoa.Do(ctx, access_token, oa.ScanQRCodeByURL(dest, imgURL))

// 图片高清化
wxoa.Do(ctx, access_token, oa.SuperreSolution(dest, filename))
wxoa.Do(ctx, access_token, oa.SuperreSolutionByURL(dest, imgURL))
OCR
// 身份证前面识别
wxoa.Do(ctx, access_token, oa.OCRIDCardFront(dest, mode, filename))
wxoa.Do(ctx, access_token, oa.OCRIDCardFrontByURL(dest, mode, imgURL))

// 身份证背面识别
wxoa.Do(ctx, access_token, oa.OCRIDCardBack(dest, mode, filename))
wxoa.Do(ctx, access_token, oa.OCRIDCardBackByURL(dest, mode, imgURL))

// 银行卡识别
wxoa.Do(ctx, access_token, oa.OCRBankCard(dest, mode, filename))
wxoa.Do(ctx, access_token, oa.OCRBankCardByURL(dest, mode, imgURL))

// 车牌号识别
wxoa.Do(ctx, access_token, oa.OCRPlateNumber(dest, mode, filename))
wxoa.Do(ctx, access_token, oa.OCRPlateNumberByURL(dest, mode, imgURL))

// 驾照识别
wxoa.Do(ctx, access_token, oa.OCRDriverLicense(dest, mode, filename))
wxoa.Do(ctx, access_token, oa.OCRDriverLicenseByURL(dest, mode, imgURL))

// 行驶证识别
wxoa.Do(ctx, access_token, oa.OCRVehicleLicense(dest, mode, filename))
wxoa.Do(ctx, access_token, oa.OCRVehicleLicenseByURL(dest, mode, imgURL))

// 营业执照识别
wxoa.Do(ctx, access_token, oa.OCRBusinessLicense(dest, mode, filename))
wxoa.Do(ctx, access_token, oa.OCRBusinessLicenseByURL(dest, mode, imgURL))

// 通用印刷体识别
wxoa.Do(ctx, access_token, oa.OCRPrintedText(dest, mode, filename))
wxoa.Do(ctx, access_token, oa.OCRPrintedTextByURL(dest, mode, imgURL))
客服
// 获取客服列表
wxoa.Do(ctx, access_token, oa.GetKFAccountList(dest))

// 获取客服在线列表
wxoa.Do(ctx, access_token, oa.GetKFOnlineList(dest))

// 添加客服账号
wxoa.Do(ctx, access_token, oa.AddKFAccount(account, nickname))

// 设置客服信息
wxoa.Do(ctx, access_token, oa.UpdateKFAccount(account, nickname))

// 邀请绑定客服帐号
wxoa.Do(ctx, access_token, oa.InviteKFWorker(account, inviteWeixin))

// 上传客服头像
wxoa.Do(ctx, access_token, oa.UploadKFAvatar(account, filename))

// 删除客服帐号
wxoa.Do(ctx, access_token, oa.DeleteKFAccount(account))

// 创建会话
wxoa.Do(ctx, access_token, oa.CreateKFSession(account, openid))

// 关闭会话
wxoa.Do(ctx, access_token, oa.CloseKFSession(account, openid))

// 获取客户会话状态
wxoa.Do(ctx, access_token, oa.GetKFSession(dest, openid))

// 获取客服会话列表
wxoa.Do(ctx, access_token, oa.GetKFSessionList(dest, account))

// 获取未接入会话列表
wxoa.Do(ctx, access_token, oa.GetKFWaitCase(dest))

// 获取聊天记录(每次查询时段不能超过24小时)
wxoa.Do(ctx, access_token, oa.GetKFMsgRecordList(dest, msgid, starttime, endtime, number))
JSSDK
// GetJSSDKTicket 获取 JS-SDK ticket (注意:使用普通access_token)
wxoa.Do(ctx, access_token, oa.GetJSSDKTicket(dest, ticket_type))

// 生成 JS-SDK 签名
wxoa.JSSDKSign(jsapi_ticket, url)
消息事件
// 验证消息事件签名
wxoa.VerifyEventSign(signature, items...)

// 事件消息解密
wxoa.DecryptEventMessage(msg_encrypt)
消息回复
// 回复文本消息
wxoa.Reply(openid, oa.NewTextReply(content))

// 回复图片消息
wxoa.Reply(openid, oa.NewImageReply(media_id))

// 回复语音消息
wxoa.Reply(openid, oa.NewVoiceReply(media_id))

// 回复视频消息
wxoa.Reply(openid, oa.NewVideoReply(media_id, title, desc))

// 回复音乐消息
wxoa.Reply(openid, oa.NewMusicReply(media_id, title, desc, music_url, HQ_music_url))

// 回复图文消息
wxoa.Reply(openid, oa.NewNewsReply(count, articles...))

// 消息转发到客服
wxoa.Reply(openid, oa.NewTransfer2KFReply(kf_account...))

Documentation

Index

Constants

View Source
const (
	CgiBinAccessTokenURL = "https://api.weixin.qq.com/cgi-bin/token"
	CgiBinTicketURL      = "https://api.weixin.qq.com/cgi-bin/ticket/getticket"
)

cgi-bin

View Source
const (
	MenuCreateURL            = "https://api.weixin.qq.com/cgi-bin/menu/create"
	MenuAddConditionalURL    = "https://api.weixin.qq.com/cgi-bin/menu/addconditional"
	MenuTryMatchURL          = "https://api.weixin.qq.com/cgi-bin/menu/trymatch"
	MenuListURL              = "https://api.weixin.qq.com/cgi-bin/menu/get"
	MenuDeleteURL            = "https://api.weixin.qq.com/cgi-bin/menu/delete"
	MenuDeleteConditionalURL = "https://api.weixin.qq.com/cgi-bin/menu/delconditional"
)

menu

View Source
const (
	SnsCode2TokenURL         = "https://api.weixin.qq.com/sns/oauth2/access_token"
	SnsCheckAccessTokenURL   = "https://api.weixin.qq.com/sns/auth"
	SnsRefreshAccessTokenURL = "https://api.weixin.qq.com/sns/oauth2/refresh_token"
	SnsUserInfoURL           = "https://api.weixin.qq.com/sns/userinfo"
)

sns

View Source
const (
	SubscriberGetURL      = "https://api.weixin.qq.com/cgi-bin/user/info"
	SubscriberBatchGetURL = "https://api.weixin.qq.com/cgi-bin/user/info/batchget"
	SubscriberListURL     = "https://api.weixin.qq.com/cgi-bin/user/get"
	BlackListGetURL       = "https://api.weixin.qq.com/cgi-bin/tags/members/getblacklist"
	BatchBlackListURL     = "https://api.weixin.qq.com/cgi-bin/tags/members/batchblacklist"
	BatchUnBlackListURL   = "https://api.weixin.qq.com/cgi-bin/tags/members/batchunblacklist"
	UserRemarkSetURL      = "https://api.weixin.qq.com/cgi-bin/user/info/updateremark"
)

subscriber

View Source
const (
	TemplateListURL         = "https://api.weixin.qq.com/cgi-bin/template/get_all_private_template"
	TemplateDeleteURL       = "https://api.weixin.qq.com/cgi-bin/template/del_private_template"
	TemplateMessageSendURL  = "https://api.weixin.qq.com/cgi-bin/message/template/send"
	SubscribeMessageSendURL = "https://api.weixin.qq.com/cgi-bin/message/template/subscribe"
)

message

View Source
const (
	QRCodeCreateURL     = "https://api.weixin.qq.com/cgi-bin/qrcode/create"
	QRCodeShowURL       = "https://mp.weixin.qq.com/cgi-bin/showqrcode"
	ShortURLGenerateURL = "https://api.weixin.qq.com/cgi-bin/shorturl"
)

popularize

View Source
const (
	MediaUploadURL     = "https://api.weixin.qq.com/cgi-bin/media/upload"
	MediaGetURL        = "https://api.weixin.qq.com/cgi-bin/media/get"
	NewsAddURL         = "https://api.weixin.qq.com/cgi-bin/material/add_news"
	NewsImageUploadURL = "https://api.weixin.qq.com/cgi-bin/media/uploadimg"
	MaterialAddURL     = "https://api.weixin.qq.com/cgi-bin/material/add_material"
	MaterialDeleteURL  = "https://api.weixin.qq.com/cgi-bin/material/del_material"
)

media

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 (
	OCRIDCardURL          = "https://api.weixin.qq.com/cv/ocr/idcard"
	OCRBankCardURL        = "https://api.weixin.qq.com/cv/ocr/bankcard"
	OCRPlateNumberURL     = "https://api.weixin.qq.com/cv/ocr/platenum"
	OCRDriverLicenseURL   = "https://api.weixin.qq.com/cv/ocr/drivinglicense"
	OCRVehicleLicenseURL  = "https://api.weixin.qq.com/cv/ocr/driving"
	OCRBusinessLicenseURL = "https://api.weixin.qq.com/cv/ocr/bizlicense"
	OCRPrintedTextURL     = "https://api.weixin.qq.com/cv/ocr/comm"
)

ocr

View Source
const (
	KFAccountListURL   = "https://api.weixin.qq.com/cgi-bin/customservice/getkflist"
	KFOnlineListURL    = "https://api.weixin.qq.com/cgi-bin/customservice/getonlinekflist"
	KFAccountAddURL    = "https://api.weixin.qq.com/customservice/kfaccount/add"
	KFInviteURL        = "https://api.weixin.qq.com/customservice/kfaccount/inviteworker"
	KFAccountUpdateURL = "https://api.weixin.qq.com/customservice/kfaccount/update"
	KFAvatarUploadURL  = "https://api.weixin.qq.com/customservice/kfaccount/uploadheadimg"
	KFDeleteURL        = "https://api.weixin.qq.com/customservice/kfaccount/del"
	KFSessionCreateURL = "https://api.weixin.qq.com/customservice/kfsession/create"
	KFSessionCloseURL  = "https://api.weixin.qq.com/customservice/kfsession/close"
	KFSessionGetURL    = "https://api.weixin.qq.com/customservice/kfsession/getsession"
	KFSessionListURL   = "https://api.weixin.qq.com/customservice/kfsession/getsessionlist"
	KFWaitCaseURL      = "https://api.weixin.qq.com/customservice/kfsession/getwaitcase"
	KFMsgRecordListURL = "https://api.weixin.qq.com/customservice/msgrecord/getmsglist"
)

KF

View Source
const AuthorizeURL = "https://open.weixin.qq.com/connect/oauth2/authorize"

oauth2

View Source
const MaxSubscriberListCount = 10000

MaxSubscriberListCount 关注列表的最大数目

Variables

This section is empty.

Functions

func AICrop

func AICrop(dest *AICropResult, filename string) wx.Action

AICrop 图片智能裁切

func AICropByURL

func AICropByURL(dest *AICropResult, imgURL string) wx.Action

AICropByURL 图片智能裁切

func AddKFAccount

func AddKFAccount(account, nickname string) wx.Action

AddKFAccount 添加客服账号 完整客服帐号,格式为:帐号前缀@公众号微信号,帐号前缀最多10个字符,必须是英文、数字字符或者下划线,后缀为公众号微信号,长度不超过30个字符 客服昵称,最长16个字

func AddMaterial

func AddMaterial(dest *MaterialAddResult, mediaType MediaType, filename string) wx.Action

AddMaterial 新增其他类型永久素材(支持图片、音频、缩略图)

func AddNews

func AddNews(dest *MaterialAddResult, articles ...*NewsArticle) wx.Action

AddNews 新增永久图文素材(公众号的素材库保存总数量有上限:图文消息素材、图片素材上限为100000,其他类型为1000)

func BatchGetSubscribers

func BatchGetSubscribers(dest *[]*SubscriberInfo, openids ...string) wx.Action

BatchGetSubscribers 批量关注用户信息

func BlackSubscribers

func BlackSubscribers(openids ...string) wx.Action

BlackSubscribers 拉黑用户

func CheckAuthToken

func CheckAuthToken(openid string) wx.Action

CheckAuthToken 检验授权凭证(access_token)是否有效

func CloseKFSession

func CloseKFSession(account, openid string) wx.Action

CloseKFSession 关闭会话 完整客服帐号,格式为:帐号前缀@公众号微信号

func CreateConditionalMenu

func CreateConditionalMenu(matchRule *MenuMatchRule, buttons ...*MenuButton) wx.Action

CreateConditionalMenu 创建个性化菜单

func CreateKFSession

func CreateKFSession(account, openid string) wx.Action

CreateKFSession 创建会话 完整客服帐号,格式为:帐号前缀@公众号微信号

func CreateMenu

func CreateMenu(buttons ...*MenuButton) wx.Action

CreateMenu 创建自定义菜单

func CreatePermQRCode

func CreatePermQRCode(dest *QRCode, senceID int) wx.Action

CreatePermQRCode 创建永久二维码(expireSeconds:二维码有效时间,最大不超过2592000秒(即30天),不填,则默认有效期为30秒。)

func CreateTempQRCode

func CreateTempQRCode(dest *QRCode, senceID int, expireSeconds ...int) wx.Action

CreateTempQRCode 创建临时二维码(expireSeconds:二维码有效时间,最大不超过2592000秒(即30天),不填,则默认有效期为30秒。)

func DeleteConditionalMenu

func DeleteConditionalMenu(menuID string) wx.Action

DeleteConditional 删除个性化菜单

func DeleteKFAccount

func DeleteKFAccount(account string) wx.Action

DeleteKFAccount 删除客服帐号 完整客服帐号,格式为:帐号前缀@公众号微信号

func DeleteMaterial

func DeleteMaterial(mediaID string) wx.Action

DeleteMaterial 删除永久素材

func DeleteMenu

func DeleteMenu() wx.Action

DeleteMenu 删除自定义菜单

func DeleteTemplate

func DeleteTemplate(templateID string) wx.Action

DeleteTemplate 删除模板

func GetAuthUser

func GetAuthUser(dest *AuthUser, openid string) wx.Action

GetAuthUser 获取授权用户信息(注意:使用网页授权的access_token)

func GetBlackList

func GetBlackList(dest *SubscriberList, beginOpenID ...string) wx.Action

GetBlackList 获取用户黑名单列表

func GetJSSDKTicket

func GetJSSDKTicket(dest *JSSDKTicket, t TicketType) wx.Action

GetJSSDKTicket 获取 JS-SDK ticket (注意:使用普通access_token)

func GetKFAccountList

func GetKFAccountList(dest *[]*KFAccount) wx.Action

GetKFAccountList 获取客服列表

func GetKFMsgRecordList

func GetKFMsgRecordList(dest *KFMsgRecordList, msgid, starttime, endtime int64, number int) wx.Action

GetKFMsgRecordList 获取聊天记录(每次查询时段不能超过24小时) 聊天记录中,对于图片、语音、视频,分别展示成文本格式的[image]、[voice]、[video]。

func GetKFOnlineList

func GetKFOnlineList(dest *[]*KFOnline) wx.Action

GetKFOnlineList 获取客服在线列表

func GetKFSession

func GetKFSession(dest *KFSession, openid string) wx.Action

GetKFSession 获取客户会话状态 获取一个客户的会话,如果不存在,则kf_account为空。

func GetKFSessionList

func GetKFSessionList(dest *[]*KFSession, account string) wx.Action

GetKFSessionList 获取客服会话列表 完整客服帐号,格式为:帐号前缀@公众号微信号

func GetKFWaitCase

func GetKFWaitCase(dest *KFWaitCase) wx.Action

GetKFWaitCase 获取未接入会话列表 最多返回100条数据,按照来访顺序

func GetMenu

func GetMenu(dest *MenuInfo) wx.Action

GetMenu 查询自定义菜单

func GetSubscriberInfo

func GetSubscriberInfo(dest *SubscriberInfo, openid string) wx.Action

GetSubscriberInfo 获取关注用户信息

func GetSubscriberList

func GetSubscriberList(dest *SubscriberList, nextOpenID ...string) wx.Action

GetSubscriberList 获取关注用户列表

func GetTemplateList

func GetTemplateList(dest *[]*TemplateInfo) wx.Action

GetTemplateList 获取模板列表

func InviteKFWorker

func InviteKFWorker(account, inviteWeixin string) wx.Action

InviteKFWorker 邀请绑定客服帐号 新添加的客服帐号是不能直接使用的,只有客服人员用微信号绑定了客服账号后,方可登录Web客服进行操作。 发起一个绑定邀请到客服人员微信号,客服人员需要在微信客户端上用该微信号确认后帐号才可用。 尚未绑定微信号的帐号可以进行绑定邀请操作,邀请未失效时不能对该帐号进行再次绑定微信号邀请。 完整客服帐号,格式为:帐号前缀@公众号微信号

func Long2ShortURL

func Long2ShortURL(dest *ShortURL, longURL string) wx.Action

Long2ShortURL 长链接转短链接(长链接支持http://、https://、weixin://wxpay格式的url)

func NewImageReply

func NewImageReply(mediaID string) event.Reply

NewImageReply 回复图片消息

func NewMusicReply

func NewMusicReply(thumbMediaID, title, desc, musicURL, HQMusicURL string) event.Reply

NewMusicReply 回复音乐消息

func NewNewsReply

func NewNewsReply(count int, articles ...*Article) event.Reply

NewNewsReply 回复图文消息

func NewTextReply

func NewTextReply(content string) event.Reply

NewTextReply 回复文本消息

func NewTransfer2KFReply

func NewTransfer2KFReply(kfAccount ...string) event.Reply

NewTransfer2KFReply 消息转发到客服

func NewVideoReply

func NewVideoReply(mediaID, title, desc string) event.Reply

NewVideoReply 回复视频消息

func NewVoiceReply

func NewVoiceReply(mediaID string) event.Reply

NewVoiceReply 回复语音消息

func OCRBankCard

func OCRBankCard(dest *BankCard, mode OCRMode, filename string) wx.Action

OCRBankCard 银行卡识别

func OCRBankCardByURL

func OCRBankCardByURL(dest *BankCard, mode OCRMode, imgURL string) wx.Action

OCRBankCardByURL 银行卡识别

func OCRBusinessLicense

func OCRBusinessLicense(dest *BusinessLicense, mode OCRMode, filename string) wx.Action

OCRBusinessLicense 营业执照识别

func OCRBusinessLicenseByURL

func OCRBusinessLicenseByURL(dest *BusinessLicense, mode OCRMode, imgURL string) wx.Action

OCRBusinessLicenseByURL 营业执照识别

func OCRDriverLicense

func OCRDriverLicense(dest *DriverLicense, mode OCRMode, filename string) wx.Action

OCRDriverLicense 驾照识别

func OCRDriverLicenseByURL

func OCRDriverLicenseByURL(dest *DriverLicense, mode OCRMode, imgURL string) wx.Action

OCRDriverLicenseByURL 驾照识别

func OCRIDCardBack

func OCRIDCardBack(dest *IDCardBack, mode OCRMode, filename string) wx.Action

OCRIDCardBack 身份证背面识别

func OCRIDCardBackByURL

func OCRIDCardBackByURL(dest *IDCardBack, mode OCRMode, imgURL string) wx.Action

OCRIDCardBackByURL 身份证背面识别

func OCRIDCardFront

func OCRIDCardFront(dest *IDCardFront, mode OCRMode, filename string) wx.Action

OCRIDCardFront 身份证前面识别

func OCRIDCardFrontByURL

func OCRIDCardFrontByURL(dest *IDCardFront, mode OCRMode, imgURL string) wx.Action

OCRIDCardFrontByURL 身份证前面识别

func OCRPlateNumber

func OCRPlateNumber(dest *PlateNumber, mode OCRMode, filename string) wx.Action

OCRPlateNumber 车牌号识别

func OCRPlateNumberByURL

func OCRPlateNumberByURL(dest *PlateNumber, mode OCRMode, imgURL string) wx.Action

OCRPlateNumberByURL 车牌号识别

func OCRPrintedText

func OCRPrintedText(dest *PrintedText, mode OCRMode, filename string) wx.Action

OCRPrintedText 通用印刷体识别

func OCRPrintedTextByURL

func OCRPrintedTextByURL(dest *PrintedText, mode OCRMode, imgURL string) wx.Action

OCRPrintedTextByURL 通用印刷体识别

func OCRVehicleLicense

func OCRVehicleLicense(dest *VehicleLicense, mode OCRMode, filename string) wx.Action

OCRVehicleLicense 行驶证识别

func OCRVehicleLicenseByURL

func OCRVehicleLicenseByURL(dest *VehicleLicense, mode OCRMode, imgURL string) wx.Action

OCRVehicleLicenseByURL 行驶证识别

func ScanQRCode

func ScanQRCode(dest *QRCodeScanResult, filename string) wx.Action

ScanQRCode 条码/二维码识别

func ScanQRCodeByURL

func ScanQRCodeByURL(dest *QRCodeScanResult, imgURL string) wx.Action

ScanQRCodeByURL 条码/二维码识别

func SendSubscribeMessage

func SendSubscribeMessage(openID, scene, title string, msg *TemplateMessage) wx.Action

SendSubscribeMessage 发送一次性订阅消息

func SendTemplateMessage

func SendTemplateMessage(openID string, msg *TemplateMessage) wx.Action

SendTemplateMessage 发送模板消息

func SetUserRemark

func SetUserRemark(openid, remark string) wx.Action

SetUserRemark 设置用户备注名(该接口暂时开放给微信认证的服务号)

func SuperreSolution

func SuperreSolution(dest *SuperreSolutionResult, filename string) wx.Action

SuperreSolution 图片高清化

func SuperreSolutionByURL

func SuperreSolutionByURL(dest *SuperreSolutionResult, imgURL string) wx.Action

SuperreSolutionByURL 图片高清化

func TryMatchMenu

func TryMatchMenu(dest *[]*MenuButton, userID string) wx.Action

TryMatchMenu 测试匹配个性化菜单 注意:user_id可以是粉丝的OpenID,也可以是粉丝的微信号。

func UnBlackSubscribers

func UnBlackSubscribers(openids ...string) wx.Action

UnBlackSubscriber 取消拉黑用户

func UpdateKFAccount

func UpdateKFAccount(account, nickname string) wx.Action

UpdateKFAccount 设置客服信息 完整客服帐号,格式为:帐号前缀@公众号微信号,帐号前缀最多10个字符,必须是英文、数字字符或者下划线,后缀为公众号微信号,长度不超过30个字符 客服昵称,最长16个字

func UploadKFAvatar

func UploadKFAvatar(account, filename string) wx.Action

UploadKFAvatar 上传客服头像 完整客服帐号,格式为:帐号前缀@公众号微信号

func UploadMedia

func UploadMedia(dest *MediaUploadResult, mediaType MediaType, filename string) wx.Action

UploadMedia 上传临时素材

func UploadNewsImage

func UploadNewsImage(dest *MaterialAddResult, filename string) wx.Action

UploadNewsImage 上传图文消息内的图片(不受公众号的素材库中图片数量的100000个的限制,图片仅支持jpg/png格式,大小必须在1MB以下)

func UploadVideo

func UploadVideo(dest *MaterialAddResult, filename, title, introduction string) wx.Action

UploadVideo 上传视频永久素材

Types

type AICropResult

type AICropResult struct {
	Results []*CropPosition `json:"results"`
	ImgSize ImageSize       `json:"img_size"`
}

AICropResult 图片裁切结果

type AccessToken

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

AccessToken 公众号普通AccessToken

type Article

type Article struct {
	Title       wx.CDATA `xml:"Title"`       // 图文消息标题
	Description wx.CDATA `xml:"Description"` // 图文消息描述
	PicURL      wx.CDATA `xml:"PicUrl"`      // 图片链接, 支持JPG, PNG格式, 较好的效果为大图360*200, 小图200*200
	URL         wx.CDATA `xml:"Url"`         // 点击图文消息跳转链接
}

Article 公众号图文

type AuthScope

type AuthScope string

AuthScope 应用授权作用域

const (
	ScopeSnsapiBase AuthScope = "snsapi_base"     // 静默授权使用,不弹出授权页面,直接跳转,只能获取用户openid
	ScopeSnsapiUser AuthScope = "snsapi_userinfo" // 弹出授权页面,可通过openid拿到昵称、性别、所在地。并且,即使在未关注的情况下,只要用户授权,也能获取其信息
)

公众号支持的应用授权作用域

type AuthToken

type AuthToken struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int64  `json:"expires_in"`
	OpenID       string `json:"openid"`
	Scope        string `json:"scope"`
}

AuthToken 公众号网页授权Token

type AuthUser

type AuthUser struct {
	OpenID     string   `json:"openid"`
	UnionID    string   `json:"unionid"`
	Nickname   string   `json:"nickname"`
	Sex        string   `json:"sex"`
	Province   string   `json:"province"`
	City       string   `json:"city"`
	Country    string   `json:"country"`
	HeadImgURL string   `json:"headimgurl"`
	Privilege  []string `json:"privilege"`
}

AuthUser 授权用户信息

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        OCRPosition `json:"cert_position"`        // 营业执照位置
	ImgSize             ImageSize   `json:"img_size"`             // 图片大小
}

BusinessLicense 营业执照

type ConditionalMenu

type ConditionalMenu struct {
	Button    []*MenuButton `json:"button"`    // 菜单按钮
	MatchRule MenuMatchRule `json:"matchrule"` // 菜单匹配规则
	MenuID    int64         `json:"menuid"`    // 菜单ID
}

ConditionalMenu 个性化菜单

type CropPosition

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

CropPosition 裁切位置

type DriverLicense

type DriverLicense struct {
	IDNum        string `json:"id_num"`        // 证号
	Name         string `json:"name"`          // 姓名
	Sex          string `json:"sex"`           // 性别
	Nationality  string `json:"nationality"`   // 国籍
	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 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 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 ImageReply

type ImageReply struct {
	ReplyHeader
	Image struct {
		MediaID wx.CDATA `xml:"MediaId"` // 通过素材管理接口上传多媒体文件得到 MediaId
	} `xml:"Image"`
}

ImageReply 公众号图片回复消息

func (*ImageReply) Bytes

func (r *ImageReply) Bytes(from, to string) ([]byte, error)

type ImageSize

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

ImageSize 图片尺寸

type JSSDKSign

type JSSDKSign struct {
	Signature string `json:"signature"`
	Noncestr  string `json:"noncestr"`
	Timestamp int64  `json:"timestamp"`
}

JSSDKSign JS-SDK签名

type JSSDKTicket

type JSSDKTicket struct {
	Ticket    string `json:"ticket"`
	ExpiresIn int64  `json:"expires_in"`
}

JSSDKTicket 公众号 JS-SDK ticket

type KFAccount

type KFAccount struct {
	ID               string         `json:"kf_id"`              // 客服编号
	Account          string         `json:"kf_account"`         // 完整客服帐号,格式为:帐号前缀@公众号微信号
	Nickname         string         `json:"kf_nick"`            // 客服昵称
	HeadImgURL       string         `json:"kf_headimgurl"`      // 客服头像
	Weixin           string         `json:"kf_wx"`              // 如果客服帐号已绑定了客服人员微信号, 则此处显示微信号
	InviteWeixin     string         `json:"invite_wx"`          // 如果客服帐号尚未绑定微信号,但是已经发起了一个绑定邀请, 则此处显示绑定邀请的微信号
	InviteExpireTime int64          `json:"invite_expire_time"` // 如果客服帐号尚未绑定微信号,但是已经发起过一个绑定邀请, 邀请的过期时间,为unix 时间戳
	InviteStatus     KFInviteStatus `json:"invite_status"`      // 邀请的状态,有等待确认“waiting”,被拒绝“rejected”, 过期“expired”
}

KFAccount 客服账号

type KFInviteStatus

type KFInviteStatus string

KFInviteStatus 客服邀请状态

const (
	InviteWaiting  KFInviteStatus = "waiting"  // 待确认
	InviteRejected KFInviteStatus = "rejected" // 被拒绝
	InviteExpired  KFInviteStatus = "expired"  // 已过期
)

微信支持的客服邀请状态

type KFMsgRecord

type KFMsgRecord struct {
	Worker   string `json:"worker"`   // 完整客服帐号,格式为:帐号前缀@公众号微信号
	OpenID   string `json:"openid"`   // 用户标识
	OperCode int    `json:"opercode"` // 操作码(2002-客服发送信息,2003-客服接收消息)
	Text     string `json:"text"`     // 聊天记录
	Time     int64  `json:"time"`     // 操作时间,unix时间戳
}

KFMsgRecord 客服聊天记录

type KFMsgRecordList

type KFMsgRecordList struct {
	MsgID      int64          `json:"msgid"`
	Number     int            `json:"number"`
	RecordList []*KFMsgRecord `json:"recordlist"`
}

KFMsgRecordList 客服聊天记录列表

type KFOnline

type KFOnline struct {
	ID           string `json:"kf_id"`         // 客服编号
	Account      string `json:"kf_account"`    // 完整客服帐号,格式为:帐号前缀@公众号微信号
	Status       int    `json:"status"`        // 客服在线状态,目前为:1-web在线
	AcceptedCase int    `json:"accepted_case"` // 客服当前正在接待的会话数
}

KFOnline 在线客服

type KFSession

type KFSession struct {
	KFAccount  string `json:"kf_account"`  // 正在接待的客服,为空表示没有人在接待
	OpenID     string `json:"openid"`      // 粉丝的openid
	CreateTime int64  `json:"createtime"`  // 会话接入的时间
	LatestTime int64  `json:"latest_time"` // 粉丝的最后一条消息的时间
}

KFSession 客服会话

type KFWaitCase

type KFWaitCase struct {
	Count int          `json:"count"`
	List  []*KFSession `json:"waitcaselist"`
}

KFWaitCase 客服未接入会话

type MaterialAddResult

type MaterialAddResult struct {
	MediaID string `json:"media_id"`
	URL     string `json:"url"`
}

MaterialAddResult 永久素材新增结果

type MediaType

type MediaType string

MediaType 素材类型

var (
	MediaImage MediaType = "image" // 图片
	MediaVoice MediaType = "voice" // 音频
	MediaVideo MediaType = "video" // 视频
	MediaThumb MediaType = "thumb" // 缩略图
)

微信支持的素材类型

type MediaUploadResult

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

MediaUploadResult 临时素材上传结果

type Menu struct {
	Button []*MenuButton `json:"button"` // 菜单按钮
	MenuID int64         `json:"menuid"` // 菜单ID(有个性化菜单时返回)
}

Menu 普通菜单

type MenuButton struct {
	Type      MenuButtonType `json:"type,omitempty"`       // 菜单的响应动作类型,view表示网页类型,click表示点击类型,miniprogram表示小程序类型
	Name      string         `json:"name,omitempty"`       // 菜单标题,不超过16个字节,子菜单不超过60个字节
	Key       string         `json:"key,omitempty"`        // click等点击类型必须,菜单KEY值,用于消息接口推送,不超过128字节
	URL       string         `json:"url,omitempty"`        // view、miniprogram类型必须,网页 链接,用户点击菜单可打开链接,不超过1024字节。 type为miniprogram时,不支持小程序的老版本客户端将打开本url。
	AppID     string         `json:"appid,omitempty"`      // miniprogram类型必须,小程序的appid(仅认证公众号可配置)
	Pagepath  string         `json:"pagepath,omitempty"`   // miniprogram类型必须,小程序的页面路径
	MediaID   string         `json:"media_id,omitempty"`   // media_id类型和view_limited类型必须,调用新增永久素材接口返回的合法media_id
	SubButton []*MenuButton  `json:"sub_button,omitempty"` // 二级菜单数组,个数应为1~5个
}

MenuButton 菜单按钮

func ClickButton

func ClickButton(name, key string) *MenuButton

ClickButton 点击事件按钮

func GroupButton

func GroupButton(name string, buttons ...*MenuButton) *MenuButton

GroupButton 组合按钮

func LocationSelectButton

func LocationSelectButton(name, key string) *MenuButton

LocationSelectButton 发送位置按钮

func MediaButton

func MediaButton(name, mediaID string) *MenuButton

MediaButton 素材按钮

func MinipButton

func MinipButton(name, appid, pagepath, redirectURL string) *MenuButton

MinipButton 小程序跳转按钮

func PicPhotoOrAlbumButton

func PicPhotoOrAlbumButton(name, key string) *MenuButton

PicPhotoOrAlbum 拍照或者相册发图按钮

func PicSysPhotoButton

func PicSysPhotoButton(name, key string) *MenuButton

PicSysPhotoButton 系统拍照发图按钮

func PicWeixinButton

func PicWeixinButton(name, key string) *MenuButton

PicWeixinButton 微信相册发图按钮

func ScanCodePushButton

func ScanCodePushButton(name, key string) *MenuButton

ScanCodePushButton 扫码推事件按钮

func ScanCodeWaitMsgButton

func ScanCodeWaitMsgButton(name, key string) *MenuButton

ScanCodeWaitMsgButton 扫码带提示按钮

func ViewButton

func ViewButton(name, redirectURL string) *MenuButton

ViewButton 跳转URL按钮

func ViewLimitedButton

func ViewLimitedButton(name, mediaID string) *MenuButton

ViewLimitedButton 图文消息按钮

type MenuButtonType string

MenuButtonType 菜单按钮类型

const (
	ButtonClick           MenuButtonType = "click"              // 点击推事件用户点击click类型按钮后,微信服务器会通过消息接口推送消息类型为event的结构给开发者(参考消息接口指南),并且带上按钮中开发者填写的key值,开发者可以通过自定义的key值与用户进行交互。
	ButtonView            MenuButtonType = "view"               // 跳转URL用户点击view类型按钮后,微信客户端将会打开开发者在按钮中填写的网页URL,可与网页授权获取用户基本信息接口结合,获得用户基本信息。
	ButtonScanCodePush    MenuButtonType = "scancode_push"      // 扫码推事件用户点击按钮后,微信客户端将调起扫一扫工具,完成扫码操作后显示扫描结果(如果是URL,将进入URL),且会将扫码的结果传给开发者,开发者可以下发消息。
	ButtonScanCodeWaitMsg MenuButtonType = "scancode_waitmsg"   // 扫码推事件且弹出“消息接收中”提示框用户点击按钮后,微信客户端将调起扫一扫工具,完成扫码操作后,将扫码的结果传给开发者,同时收起扫一扫工具,然后弹出“消息接收中”提示框,随后可能会收到开发者下发的消息。
	ButtonPicSysPhoto     MenuButtonType = "pic_sysphoto"       // 弹出系统拍照发图用户点击按钮后,微信客户端将调起系统相机,完成拍照操作后,会将拍摄的相片发送给开发者,并推送事件给开发者,同时收起系统相机,随后可能会收到开发者下发的消息。
	ButtonPicPhotoOrAlbum MenuButtonType = "pic_photo_or_album" // 弹出拍照或者相册发图用户点击按钮后,微信客户端将弹出选择器供用户选择“拍照”或者“从手机相册选择”。用户选择后即走其他两种流程。
	ButtonPicWeixin       MenuButtonType = "pic_weixin"         // 弹出微信相册发图器用户点击按钮后,微信客户端将调起微信相册,完成选择操作后,将选择的相片发送给开发者的服务器,并推送事件给开发者,同时收起相册,随后可能会收到开发者下发的消息。
	ButtonLocationSelect  MenuButtonType = "location_select"    // 弹出地理位置选择器用户点击按钮后,微信客户端将调起地理位置选择工具,完成选择操作后,将选择的地理位置发送给开发者的服务器,同时收起位置选择工具,随后可能会收到开发者下发的消息。
	ButtonMedia           MenuButtonType = "media_id"           // 下发消息(除文本消息)用户点击media_id类型按钮后,微信服务器会将开发者填写的永久素材id对应的素材下发给用户,永久素材类型可以是图片、音频、视频、图文消息。请注意:永久素材id必须是在“素材管理/新增永久素材”接口上传后获得的合法id。
	ButtonViewLimited     MenuButtonType = "view_limited"       // 跳转图文消息URL用户点击view_limited类型按钮后,微信客户端将打开开发者在按钮中填写的永久素材id对应的图文消息URL,永久素材类型只支持图文消息。请注意:永久素材id必须是在“素材管理/新增永久素材”接口上传后获得的合法id。​
	ButtonMinip           MenuButtonType = "miniprogram"        // 小程序页面跳转,不支持小程序的老版本客户端将打开指定的URL。
)

微信支持的按钮

type MenuInfo struct {
	Menu            Menu               `json:"menu"`            // 普通菜单
	ConditionalMenu []*ConditionalMenu `json:"conditionalmenu"` // 个性化菜单
}

MenuInfo 自定义菜单信息

type MenuMatchRule struct {
	TagID              string `json:"tag_id,omitempty"`               // 用户标签的id,可通过用户标签管理接口获取,不填则不做匹配
	Sex                string `json:"sex,omitempty"`                  // 性别:男(1)女(2),不填则不做匹配
	Country            string `json:"country,omitempty"`              // 国家信息,是用户在微信中设置的地区,具体请参考地区信息表,不填则不做匹配
	Province           string `json:"province,omitempty"`             // 省份信息,是用户在微信中设置的地区,具体请参考地区信息表,不填则不做匹配
	City               string `json:"city,omitempty"`                 // 城市信息,是用户在微信中设置的地区,具体请参考地区信息表,不填则不做匹配
	ClientPlatformType string `json:"client_platform_type,omitempty"` // 客户端版本,当前只具体到系统型号:IOS(1), Android(2),Others(3),不填则不做匹配
	Language           string `json:"language,omitempty"`             // 语言信息,是用户在微信中设置的语言,具体请参考语言表,不填则不做匹配
}

MenuMatchRule 菜单匹配规则

type MessageBody

type MessageBody map[string]map[string]string

MessageBody 消息内容体

type MessageMinip

type MessageMinip struct {
	AppID    string `json:"appid"`    // 所需跳转到的小程序appid(该小程序appid必须与发模板消息的公众号是绑定关联关系,暂不支持小游戏)
	Pagepath string `json:"pagepath"` // 所需跳转到小程序的具体页面路径,支持带参数,(示例index?foo=bar),要求该小程序已发布,暂不支持小游戏
}

MessageMinip 跳转小程序

type MusicReply

type MusicReply struct {
	ReplyHeader
	Music struct {
		Title        wx.CDATA `xml:"Title,omitempty"`       // 音乐标题
		Description  wx.CDATA `xml:"Description,omitempty"` // 音乐描述
		MusicURL     wx.CDATA `xml:"MusicUrl,omitempty"`    // 音乐链接
		HQMusicURL   wx.CDATA `xml:"HQMusicUrl,omitempty"`  // 高质量音乐链接, WIFI环境优先使用该链接播放音乐
		ThumbMediaID wx.CDATA `xml:"ThumbMediaId"`          // 通过素材管理接口上传多媒体文件得到 ThumbMediaId
	} `xml:"Music"`
}

MusicReply 公众号音乐回复

func (*MusicReply) Bytes

func (r *MusicReply) Bytes(from, to string) ([]byte, error)

type NewsArticle

type NewsArticle struct {
	Title              string `json:"title"`
	ThumbMediaID       string `json:"thumb_media_id"`
	Author             string `json:"author"`
	Digest             string `json:"digest"`
	ShowCoverPic       int    `json:"show_cover_pic"`
	Content            string `json:"content"`
	ContentSourceURL   string `json:"content_source_url"`
	NeedOpenComment    int    `json:"need_open_comment"`
	OnlyFansCanComment int    `json:"only_fans_can_comment"`
}

NewsArticle 文章素材

type NewsReply

type NewsReply struct {
	ReplyHeader
	ArticleCount int        `xml:"ArticleCount"`  // 图文消息个数, 限制为10条以内
	Articles     []*Article `xml:"Articles>item"` // 多条图文消息信息, 默认第一个item为大图, 注意, 如果图文数超过10, 则将会无响应
}

NewsReply 公众号图文回复

func (*NewsReply) Bytes

func (r *NewsReply) Bytes(from, to string) ([]byte, error)

type OA

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

OA 微信公众号

func New

func New(appid, appsecret string) *OA

New returns new OA

func (*OA) AccessToken

func (oa *OA) AccessToken(ctx context.Context, options ...wx.HTTPOption) (*AccessToken, error)

AccessToken 获取普通AccessToken

func (*OA) AuthURL

func (oa *OA) AuthURL(scope AuthScope, redirectURL string) string

AuthURL 生成网页授权URL(请使用 URLEncode 对 redirectURL 进行处理)

func (*OA) Code2AuthToken

func (oa *OA) Code2AuthToken(ctx context.Context, code string, options ...wx.HTTPOption) (*AuthToken, error)

Code2AuthToken 获取网页授权AccessToken

func (*OA) DecryptEventMessage

func (oa *OA) DecryptEventMessage(encrypt string) (wx.WXML, error)

DecryptEventMessage 事件消息解密

func (*OA) Do

func (oa *OA) Do(ctx context.Context, accessToken string, action wx.Action, options ...wx.HTTPOption) error

Do exec action

func (*OA) JSSDKSign

func (oa *OA) JSSDKSign(jsapiTicket, url string) *JSSDKSign

JSSDKSign 生成 JS-SDK 签名

func (*OA) RefreshAuthToken

func (oa *OA) RefreshAuthToken(ctx context.Context, refreshToken string, options ...wx.HTTPOption) (*AuthToken, error)

RefreshAuthToken 刷新网页授权AccessToken

func (*OA) Reply

func (oa *OA) Reply(openid string, reply event.Reply) (*event.ReplyMessage, error)

Reply 消息回复

func (*OA) SetOriginID

func (oa *OA) SetOriginID(originid string)

SetOriginID 设置原始ID(开发者微信号)

func (*OA) SetServerConfig

func (oa *OA) SetServerConfig(token, encodingAESKey string)

SetServerConfig 设置服务器配置 [参考](https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Access_Overview.html)

func (*OA) VerifyEventSign

func (oa *OA) VerifyEventSign(signature string, items ...string) bool

VerifyEventSign 验证消息事件签名 验证消息来自微信服务器,使用:signature、timestamp、nonce;若验证成功,请原样返回echostr参数内容 验证事件消息签名,使用:msg_signature、timestamp、nonce、msg_encrypt [参考](https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Access_Overview.html)

type OCRMode

type OCRMode string

OCRMode 识别模式

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

微信支持的识别模式

type OCRPosition

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

OCRPosition 识别位置

type PlateNumber

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

PlateNumber 车牌号

type Position

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

Position 位置信息

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 {
	Ticket        string `json:"ticket"`
	ExpireSeconds int64  `json:"expire_seconds"`
	URL           string `json:"url"`
}

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 ReplyHeader

type ReplyHeader struct {
	XMLName      xml.Name `xml:"xml"`
	FromUserName wx.CDATA `xml:"FromUserName"`
	ToUserName   wx.CDATA `xml:"ToUserName"`
	CreateTime   int64    `xml:"CreateTime"`
	MsgType      wx.CDATA `xml:"MsgType"`
}

ReplyHeader 公众号消息回复公共头

type ShortURL

type ShortURL struct {
	URL string
}

ShortURL 短链接

type SubscribeScene

type SubscribeScene string

SubscribeScene 关注的渠道来源

const (
	SceneSearch           SubscribeScene = "ADD_SCENE_SEARCH"               // 公众号搜索
	SceneQRCode           SubscribeScene = "ADD_SCENE_QR_CODE"              // 扫描二维码
	SceneAccountMigration SubscribeScene = "ADD_SCENE_ACCOUNT_MIGRATION"    // 公众号迁移
	SceneProfileCard      SubscribeScene = "ADD_SCENE_PROFILE_CARD"         // 名片分享
	SceneProfileLink      SubscribeScene = "ADD_SCENE_PROFILE_LINK"         // 图文页内名称点击
	SceneProfileItem      SubscribeScene = "ADD_SCENE_PROFILE_ITEM"         // 图文页右上角菜单
	ScenePaid             SubscribeScene = "ADD_SCENE_PAID"                 // 支付后关注
	SceneWechatAD         SubscribeScene = "ADD_SCENE_WECHAT_ADVERTISEMENT" // 微信广告
	SceneOthers           SubscribeScene = "ADD_SCENE_OTHERS"               // 其他
)

微信支持的关注的渠道来源

type SubscriberInfo

type SubscriberInfo struct {
	Subscribe      int            `json:"subscribe"`       // 用户是否订阅该公众号标识,值为0时,代表此用户没有关注该公众号,拉取不到其余信息。
	OpenID         string         `json:"openid"`          // 用户的标识,对当前公众号唯一
	NickName       string         `json:"nickname"`        // 用户的昵称
	Sex            int            `json:"sex"`             // 用户的性别,男(1),女(2),未知(0)
	Country        string         `json:"country"`         // 用户所在国家
	City           string         `json:"city"`            // 用户所在城市
	Province       string         `json:"province"`        // 用户所在省份
	Language       string         `json:"language"`        // 用户的语言,简体中文为zh_CN
	HeadImgURL     string         `json:"headimgurl"`      // 用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空。若用户更换头像,原有头像URL将失效。
	SubscribeTime  int64          `json:"subscribe_time"`  // 用户关注时间,为时间戳。如果用户曾多次关注,则取最后关注时间
	UnionID        string         `json:"unionid"`         // 只有在用户将公众号绑定到微信开放平台帐号后,才会出现该字段。
	Remark         string         `json:"remark"`          // 公众号运营者对粉丝的备注,公众号运营者可在微信公众平台用户管理界面对粉丝添加备注
	GroupID        int64          `json:"groupid"`         // 用户所在的分组ID(兼容旧的用户分组接口)
	TagidList      []int64        `json:"tagid_list"`      // 用户被打上的标签ID列表
	SubscribeScene SubscribeScene `json:"subscribe_scene"` // 用户关注的渠道来源
	QRScene        int64          `json:"qr_scene"`        // 二维码扫码场景(开发者自定义)
	QRSceneStr     string         `json:"qr_scene_str"`    // 二维码扫码场景描述(开发者自定义)
}

SubscriberInfo 关注用户信息

type SubscriberList

type SubscriberList struct {
	Total      int                `json:"total"`
	Count      int                `json:"count"`
	Data       SubscriberListData `json:"data"`
	NextOpenID string             `json:"next_openid"`
}

SubscriberList 关注列表

type SubscriberListData

type SubscriberListData struct {
	OpenID []string `json:"openid"`
}

SubscriberListData 关注列表数据

type SuperreSolutionResult

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

SuperreSolutionResult 图片高清化结果

type TemplateInfo

type TemplateInfo struct {
	TemplateID      string `json:"template_id"`      // 模板ID
	Title           string `json:"title"`            // 模板标题
	PrimaryIndustry string `json:"primary_industry"` // 模板所属行业的一级行业
	DeputyIndustry  string `json:"deputy_industry"`  // 模板所属行业的二级行业
	Content         string `json:"content"`          // 模板内容
	Example         string `json:"example"`          // 模板示例
}

TemplateInfo 模板信息

type TemplateMessage

type TemplateMessage struct {
	TemplateID  string        // 模板ID
	URL         string        // 模板跳转链接(海外帐号没有跳转能力)
	MiniProgram *MessageMinip // 跳转小程序
	Data        MessageBody   // 模板内容,格式形如:{"key1":{"value":"V","color":"#"},"key2":{"value": "V","color":"#"}}
}

TemplateMessage 公众号模板消息

type TextReply

type TextReply struct {
	ReplyHeader
	Content wx.CDATA `xml:"Content"`
}

TextReply 公众号文本回复

func (*TextReply) Bytes

func (r *TextReply) Bytes(from, to string) ([]byte, error)

type TicketType

type TicketType string

JS-SDK ticket 类型

const (
	APITicket   TicketType = "wx_card"
	JSAPITicket TicketType = "jsapi"
)

微信支持的 JS-SDK ticket

type TransInfo

type TransInfo struct {
	KFAccount wx.CDATA `xml:"KfAccount"`
}

TransInfo 转发客服账号

type Transfer2KFReply

type Transfer2KFReply struct {
	ReplyHeader
	TransInfo *TransInfo `xml:"TransInfo,omitempty"`
}

Transfer2KFReply 公众号消息转客服

func (*Transfer2KFReply) Bytes

func (r *Transfer2KFReply) Bytes(from, to string) ([]byte, error)

type VehicleLicense

type VehicleLicense struct {
	VehicleType       string      `json:"vhicle_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"`          // 发证日期
	PlateNum          string      `json:"plate_num"`           // 车牌号码
	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"`     // 整备质量
	OverallSize       string      `json:"overall_size"`        // 外廓尺寸
	CardPositionFront OCRPosition `json:"card_position_front"` // 卡片正面位置(检测到卡片正面才会返回)
	CardPositionBack  OCRPosition `json:"card_position_back"`  // 卡片反面位置(检测到卡片反面才会返回)
}

VehicleLicense 行驶证

type VideoReply

type VideoReply struct {
	ReplyHeader
	Video struct {
		MediaID     wx.CDATA `xml:"MediaId"`               // 通过素材管理接口上传多媒体文件得到 MediaId
		Title       wx.CDATA `xml:"Title,omitempty"`       // 视频消息的标题, 可以为空
		Description wx.CDATA `xml:"Description,omitempty"` // 视频消息的描述, 可以为空
	} `xml:"Video" json:"Video"`
}

VideoReply 公众号视频回复

func (*VideoReply) Bytes

func (r *VideoReply) Bytes(from, to string) ([]byte, error)

type VoiceReply

type VoiceReply struct {
	ReplyHeader
	Voice struct {
		MediaID wx.CDATA `xml:"MediaId"` // 通过素材管理接口上传多媒体文件得到 MediaId
	} `xml:"Voice"`
}

VoiceReply 公众号语音回复

func (*VoiceReply) Bytes

func (r *VoiceReply) Bytes(from, to string) ([]byte, error)

Jump to

Keyboard shortcuts

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