openplatform

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package openplatform 微信开放平台API - 调用授权方接口

Package openplatform 微信开放平台API - 第三方平台域名设置 参考:

Package openplatform 微信开放平台API - 启动票据推送服务 参考:https://developers.weixin.qq.com/doc/oplatform/openApi/ticket-token/api_startpushticket.html

Package openplatform 微信开放平台API - 代小程序代码管理 参考:https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/commit.html

Index

Constants

View Source
const (
	// 组件OAuth
	URLComponentOAuth2AccessToken = core.BaseAPIURL + "/sns/oauth2/component/access_token"
	URLComponentOAuth2UserInfo    = core.BaseAPIURL + "/sns/userinfo"

	// 组件基础接口
	URLComponentToken      = core.BaseAPIURL + "/cgi-bin/component/api_component_token"
	URLPreAuthCode         = core.BaseAPIURL + "/cgi-bin/component/api_create_preauthcode"
	URLQueryAuth           = core.BaseAPIURL + "/cgi-bin/component/api_query_auth"
	URLAuthorizerToken     = core.BaseAPIURL + "/cgi-bin/component/api_authorizer_token"
	URLGetAuthorizerInfo   = core.BaseAPIURL + "/cgi-bin/component/api_get_authorizer_info"
	URLGetAuthorizerList   = core.BaseAPIURL + "/cgi-bin/component/api_get_authorizer_list"
	URLGetAuthorizerOption = core.BaseAPIURL + "/cgi-bin/component/api_get_authorizer_option"
	URLSetAuthorizerOption = core.BaseAPIURL + "/cgi-bin/component/api_set_authorizer_option"
	URLStartPushTicket     = core.BaseAPIURL + "/cgi-bin/component/api_start_push_ticket"
	// URLClearComponentQuota 使用AppSecret重置第三方平台API调用次数(v2 版本,无 query 参数)
	// 参考:https://developers.weixin.qq.com/doc/oplatform/openApi/openapi/api_componentclearquota_v2.html
	URLClearComponentQuota = core.BaseAPIURL + "/cgi-bin/component/clear_quota/v2"
	URLModifyServerDomain  = core.BaseAPIURL + "/cgi-bin/component/modify_wxa_server_domain"
	URLModifyJumpDomain    = core.BaseAPIURL + "/cgi-bin/component/modify_wxa_jump_domain"

	// 通用接口
	URLClearQuota  = core.BaseAPIURL + "/cgi-bin/clear_quota"
	URLGetApiQuota = core.BaseAPIURL + "/cgi-bin/openapi/quota/get"
	URLGetRidInfo  = core.BaseAPIURL + "/cgi-bin/openapi/rid/get"

	// 小程序
	URLWxaGetTemplateDraftList = core.BaseAPIURL + "/wxa/gettemplatedraftlist"
	URLWxaAddToTemplate        = core.BaseAPIURL + "/wxa/addtotemplate"
	URLWxaGetTemplateList      = core.BaseAPIURL + "/wxa/gettemplatelist"
	URLWxaDeleteTemplate       = core.BaseAPIURL + "/wxa/deletetemplate"

	// 代小程序代码管理(使用 authorizer_access_token 调用)
	// 参考:https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/commit.html
	URLWxaCommit           = core.BaseAPIURL + "/wxa/commit"
	URLWxaGetQrcode        = core.BaseAPIURL + "/wxa/get_qrcode"
	URLWxaGetCategory      = core.BaseAPIURL + "/wxa/get_category"
	URLWxaSubmitAudit      = core.BaseAPIURL + "/wxa/submit_audit"
	URLWxaGetAuditStatus   = core.BaseAPIURL + "/wxa/get_auditstatus"
	URLWxaRelease          = core.BaseAPIURL + "/wxa/release"
	URLWxaRevertRelease    = core.BaseAPIURL + "/wxa/revertcoderelease"
	URLWxaUploadAuditMedia = core.BaseAPIURL + "/wxa/uploadmedia"

	// 小程序码
	URLGetWxaCode = core.BaseAPIURL + "/wxa/getwxacode"

	// URLSnsOAuth2ComponentRefreshToken 第三方平台代公众号刷新**网页授权** access_token
	// 注意:刷新「授权方 access_token」请使用 URLAuthorizerToken(api_authorizer_token),两者不可混用
	// 参考:https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Before_Develop/official_account/refresh_token.html
	URLSnsOAuth2ComponentRefreshToken = core.BaseAPIURL + "/sns/oauth2/component/refresh_token"
)

微信开放平台API地址常量

View Source
const (
	// AuthTypeOfficialAccount 公众号授权
	AuthTypeOfficialAccount = 1

	// AuthTypeMiniProgram 小程序授权
	AuthTypeMiniProgram = 2

	// AuthTypeBoth 公众号和小程序都展示
	AuthTypeBoth = 3

	// AuthTypeMiniProgramPromoter 小程序推客账号
	AuthTypeMiniProgramPromoter = 4

	// AuthTypeChannels 视频号账号
	AuthTypeChannels = 5

	// AuthTypeAll 全部
	AuthTypeAll = 6

	// AuthTypeLiveStreamingAssistant 带货助手账号
	AuthTypeLiveStreamingAssistant = 8
)

授权类型常量

View Source
const (
	DomainActionAdd    = "add"    // 添加(删除不存在的域名视为成功)
	DomainActionDelete = "delete" // 删除
	DomainActionSet    = "set"    // 覆盖
	DomainActionGet    = "get"    // 获取(同时返回测试版和全网发布版)
)

域名操作类型(action)

View Source
const (
	// InfoTypeAuthorized 授权成功事件
	// 当公众号/服务号/小程序/微信小店/带货助手/视频号助手对第三方平台进行授权时触发
	InfoTypeAuthorized = "authorized"

	// InfoTypeUnauthorized 取消授权事件
	// 当公众号/服务号/小程序/微信小店/带货助手/视频号助手取消对第三方平台的授权时触发
	InfoTypeUnauthorized = "unauthorized"

	// InfoTypeUpdateAuthorized 授权更新事件
	// 当授权方更新授权时触发。如果更新授权时,授权的权限集没有发生变化,将不会触发授权更新通知
	InfoTypeUpdateAuthorized = "updateauthorized"

	// InfoTypeComponentVerifyTicket 验证票据推送事件
	// 微信服务器每隔10分钟推送component_verify_ticket到第三方平台的消息接收URL
	// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Before_Develop/component_verify_ticket.html
	InfoTypeComponentVerifyTicket = "component_verify_ticket"
)

授权变更事件类型常量 对应微信官方文档中的InfoType字段说明 https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Before_Develop/authorize_event.html

View Source
const (
	WxaAuditStatusApproved  = 0 // 审核成功
	WxaAuditStatusRejected  = 1 // 审核被拒绝
	WxaAuditStatusAuditing  = 2 // 审核中
	WxaAuditStatusWithdrawn = 3 // 已撤回
	WxaAuditStatusDelayed   = 4 // 审核延后
)

代小程序审核状态(GetWxaAuditStatusResponse.Status)

Variables

View Source
var (
	ErrInvalidURL        = errors.New("invalid URL format")
	ErrEmptyJSAPIList    = errors.New("JSAPI list cannot be empty")
	ErrEmptyAppID        = errors.New("authorizer AppID cannot be empty")
	ErrCacheMiss         = errors.New("cache miss or expired")
	ErrInvalidMaxRetries = errors.New("max retries must be greater than 0")
	ErrTicketFetchFailed = errors.New("failed to fetch JSAPI ticket")
	ErrAccessTokenFailed = errors.New("failed to get authorizer access token")
)

标准错误定义

Functions

This section is empty.

Types

type AddToTemplateRequest

type AddToTemplateRequest struct {
	DraftID      int64 `json:"draft_id"`
	TemplateType int   `json:"template_type"`
}

AddToTemplateRequest 将草稿添加到模板库请求

type Article

type Article struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	URL         string `json:"url"`
	PicURL      string `json:"picurl"`
}

Article 图文消息文章

type AuthClient

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

AuthClient 授权相关客户端

func NewAuthClient

func NewAuthClient(client *Client) *AuthClient

NewAuthClient 创建授权客户端

func (*AuthClient) NewAuthorizerClient

func (c *AuthClient) NewAuthorizerClient(authorizerAppID string) *AuthorizerClient

NewAuthorizerClient 创建授权方API客户端

type AuthorizationEvent

type AuthorizationEvent struct {
	AppId                        string `xml:"AppId" json:"appid"`
	CreateTime                   int64  `xml:"CreateTime" json:"create_time"`
	InfoType                     string `xml:"InfoType" json:"info_type"`
	AuthorizerAppid              string `xml:"AuthorizerAppid" json:"authorizer_appid"`
	AuthorizationCode            string `xml:"AuthorizationCode,omitempty" json:"authorization_code,omitempty"`
	AuthorizationCodeExpiredTime int64  `xml:"AuthorizationCodeExpiredTime,omitempty" json:"authorization_code_expired_time,omitempty"`
	PreAuthCode                  string `xml:"PreAuthCode,omitempty" json:"pre_auth_code,omitempty"`
}

AuthorizationEvent 授权变更事件基础结构 对应微信官方文档中的授权变更通知推送格式 https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Before_Develop/authorize_event.html 所有授权变更事件共有的字段 接收POST请求后,只需直接返回字符串success 字段说明: - AppId: 第三方平台appid - CreateTime: 时间戳 - InfoType: 通知类型 - AuthorizerAppid: 公众号/服务号/小程序/微信小店/带货助手/视频号助手的appid - AuthorizationCode: 授权码,可用于获取授权信息(仅authorized和updateauthorized事件) - AuthorizationCodeExpiredTime: 授权码过期时间 单位秒(仅authorized和updateauthorized事件) - PreAuthCode: 预授权码(仅authorized和updateauthorized事件)

type AuthorizationInfo

type AuthorizationInfo struct {
	AuthorizerAppID        string     `json:"authorizer_appid"`
	AuthorizerAccessToken  string     `json:"authorizer_access_token"`
	ExpiresIn              int        `json:"expires_in"` // authorizer_access_token的有效期
	AuthorizerRefreshToken string     `json:"authorizer_refresh_token"`
	FuncInfo               []FuncInfo `json:"func_info"`
}

AuthorizationInfo 授权信息

type AuthorizedEvent

type AuthorizedEvent struct {
	AuthorizationEvent
}

AuthorizedEvent 授权成功事件 InfoType: authorized 当公众号/服务号/小程序/微信小店/带货助手/视频号助手对第三方平台进行授权时触发

type AuthorizerClient

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

AuthorizerClient 授权方API客户端

func (*AuthorizerClient) CallAPI

func (c *AuthorizerClient) CallAPI(ctx context.Context, apiURL string, params interface{}) ([]byte, error)

CallAPI 代调用API(支持context)

func (*AuthorizerClient) CallAPIWithQuery

func (c *AuthorizerClient) CallAPIWithQuery(ctx context.Context, baseURL string, queryParams map[string]string, postData interface{}) ([]byte, error)

CallAPIWithQuery 支持查询参数的API调用

说明: access_token 由 CallAPI 统一注入,此处仅拼接业务查询参数, 避免 access_token 被二次拼接导致参数污染(历史缺陷,已修复)。

func (*AuthorizerClient) CallAPIWithRetry

func (c *AuthorizerClient) CallAPIWithRetry(ctx context.Context, apiURL string, params interface{}, maxRetries int) ([]byte, error)

CallAPIWithRetry 带重试的API调用 遇到 40001(access_token 无效)/ 42001(access_token 过期)时会将本地缓存的 授权方 access_token 置为过期(保留 refresh_token)并重新获取后重试;其他错误直接返回

func (*AuthorizerClient) Create

Create 创建二维码

func (*AuthorizerClient) CreateConditionalMenu

func (c *AuthorizerClient) CreateConditionalMenu(ctx context.Context, menu *ConditionalMenu) error

CreateConditionalMenu 创建个性化菜单

func (*AuthorizerClient) CreateMenu

func (c *AuthorizerClient) CreateMenu(ctx context.Context, menu *Menu) error

CreateMenu 创建自定义菜单

func (*AuthorizerClient) DeleteConditionalMenu

func (c *AuthorizerClient) DeleteConditionalMenu(ctx context.Context, menuID string) error

DeleteConditionalMenu 删除个性化菜单

func (*AuthorizerClient) DeleteMenu

func (c *AuthorizerClient) DeleteMenu(ctx context.Context) error

DeleteMenu 删除自定义菜单

func (*AuthorizerClient) GetJSSDKManager

func (c *AuthorizerClient) GetJSSDKManager() *JSSDKManager

GetJSSDKManager 创建JS-SDK管理器

func (*AuthorizerClient) GetMedia

func (c *AuthorizerClient) GetMedia(ctx context.Context, mediaID string) ([]byte, error)

GetMedia 获取临时素材

func (*AuthorizerClient) GetMenu

func (c *AuthorizerClient) GetMenu(ctx context.Context) (*Menu, error)

GetMenu 获取菜单

func (*AuthorizerClient) GetMiniProgramClient

func (c *AuthorizerClient) GetMiniProgramClient() *MiniProgramClient

GetMiniProgramClient 创建小程序客户端

func (*AuthorizerClient) GetOAuthClient

func (c *AuthorizerClient) GetOAuthClient(redirectURI string) *OAuthClient

GetOAuthClient 创建OAuth客户端

func (*AuthorizerClient) GetQRCodeURL

func (c *AuthorizerClient) GetQRCodeURL(ticket string) (string, error)

GetQRCodeURL 获取二维码图片URL

func (*AuthorizerClient) GetUserInfo

func (c *AuthorizerClient) GetUserInfo(ctx context.Context, openID string) (*UserInfo, error)

GetUserInfo 获取用户信息

func (*AuthorizerClient) GetUserList

func (c *AuthorizerClient) GetUserList(ctx context.Context, nextOpenID string) (*UserList, error)

GetUserList 获取用户列表

func (*AuthorizerClient) SendCustomMessage

func (c *AuthorizerClient) SendCustomMessage(ctx context.Context, toUser string, message interface{}) error

SendCustomMessage 发送客服消息

func (*AuthorizerClient) SendImageMessage

func (c *AuthorizerClient) SendImageMessage(ctx context.Context, toUser, mediaID string) error

SendImageMessage 发送图片消息

func (*AuthorizerClient) SendNewsMessage

func (c *AuthorizerClient) SendNewsMessage(ctx context.Context, toUser string, articles []Article) error

SendNewsMessage 发送图文消息

func (*AuthorizerClient) SendTemplateMessage

SendTemplateMessage 发送模板消息

func (*AuthorizerClient) SendTextMessage

func (c *AuthorizerClient) SendTextMessage(ctx context.Context, toUser, content string) error

SendTextMessage 发送文本消息

func (*AuthorizerClient) UploadMedia

func (c *AuthorizerClient) UploadMedia(ctx context.Context, mediaType, filename string, data []byte) (*MediaResponse, error)

UploadMedia 上传临时素材

type AuthorizerInfo

type AuthorizerInfo struct {
	NickName        string          `json:"nick_name"`
	HeadImg         string          `json:"head_img"`
	ServiceTypeInfo ServiceTypeInfo `json:"service_type_info"`
	VerifyTypeInfo  VerifyTypeInfo  `json:"verify_type_info"`
	UserName        string          `json:"user_name"`
	PrincipalName   string          `json:"principal_name"`
	BusinessInfo    BusinessInfo    `json:"business_info"`
	Alias           string          `json:"alias"`
	QrcodeURL       string          `json:"qrcode_url"`
	Signature       string          `json:"signature"`
	// MiniProgramInfo 小程序信息。
	// 注意:官方接口返回的 JSON 键即为首字母大写的 "MiniProgramInfo"(微信历史原因),
	// 请勿「修正」为小写,否则该字段永远解析不到。
	MiniProgramInfo *MiniProgramInfo `json:"MiniProgramInfo,omitempty"`
	RegisterType    int              `json:"register_type"`
	AccountStatus   int              `json:"account_status"`
	BasicConfig     *BasicConfigInfo `json:"basic_config,omitempty"`
	ChannelsInfo    *ChannelsInfo    `json:"channels_info,omitempty"`
	// IDC idc 查询机房信息(官方 api_get_authorizer_info 返回字段)
	IDC string `json:"idc,omitempty"`
}

AuthorizerInfo 授权方信息

type AuthorizerTokenRequest

type AuthorizerTokenRequest struct {
	ComponentAppID         string `json:"component_appid"`
	AuthorizerAppID        string `json:"authorizer_appid"`
	AuthorizerRefreshToken string `json:"authorizer_refresh_token"`
}

AuthorizerTokenRequest 刷新授权方token请求参数

type AuthorizerTokenResponse

type AuthorizerTokenResponse struct {
	core.APIResponse
	AuthorizerAccessToken  string `json:"authorizer_access_token"`
	ExpiresIn              int    `json:"expires_in"`
	AuthorizerRefreshToken string `json:"authorizer_refresh_token"`
}

AuthorizerTokenResponse 授权方token响应

type BasicConfigInfo

type BasicConfigInfo struct {
	IsPhoneConfigured bool `json:"is_phone_configured"`
	IsEmailConfigured bool `json:"is_email_configured"`
}

BasicConfigInfo 基础配置信息

type BusinessInfo

type BusinessInfo struct {
	OpenStore int `json:"open_store"`
	OpenScan  int `json:"open_scan"`
	OpenPay   int `json:"open_pay"`
	OpenCard  int `json:"open_card"`
	OpenShake int `json:"open_shake"`
}

BusinessInfo 商业功能开通情况

type Button

type Button struct {
	Type      string   `json:"type,omitempty"`
	Name      string   `json:"name"`
	Key       string   `json:"key,omitempty"`
	URL       string   `json:"url,omitempty"`
	SubButton []Button `json:"sub_button,omitempty"`
}

Button 菜单按钮

type CacheStats added in v0.0.5

type CacheStats struct {
	Hits       int64 // 缓存命中次数
	Misses     int64 // 缓存未命中次数
	Evictions  int64 // 缓存淘汰次数
	TotalItems int64 // 总缓存项数
}

CacheStats 缓存统计信息

type Category

type Category struct {
	First  string `json:"first"`
	Second string `json:"second"`
}

Category 小程序类目

type ChannelsInfo

type ChannelsInfo struct {
	ID int `json:"id"`
}

ChannelsInfo 视频号账号类型;如果该授权账号为视频号则返回该字段

type ClearComponentQuotaRequest

type ClearComponentQuotaRequest struct {
	ComponentAppID string `json:"component_appid"` // 第三方平台appid
	AppSecret      string `json:"appsecret"`       // 第三方平台appsecret
	AppID          string `json:"appid,omitempty"` // 代重置时填写已授权的公众号/小程序appid,留空表示重置第三方平台自身
}

ClearComponentQuotaRequest 使用AppSecret重置第三方平台API调用次数请求 参考文档:https://developers.weixin.qq.com/doc/oplatform/openApi/openapi/api_componentclearquota_v2.html 接口说明:POST https://api.weixin.qq.com/cgi-bin/component/clear_quota/v2(**无 query 参数**,仅支持 POST) 请求体:

重置第三方平台自身:{"component_appid":"...","appsecret":"..."}
代公众号/小程序重置:{"appid":"...","component_appid":"...","appsecret":"..."}

注意事项:

  1. 该接口通过 appsecret 调用,用于解决 access_token 已耗尽无法调用 clear_quota 的场景
  2. 与 clear_quota 共用每月 10 次清零机会
  3. 字段名是 appsecret,不是 component_appsecret

type ClearQuotaRequest

type ClearQuotaRequest struct {
	AppID string `json:"appid"` // 要被清空的账号的appid
}

ClearQuotaRequest 重置API调用次数请求 参考文档:https://developers.weixin.qq.com/doc/service/api/apimanage/api_clearquota.html 接口说明:POST https://api.weixin.qq.com/cgi-bin/clear_quota?access_token=ACCESS_TOKEN 请求体只包含一个字段 {"appid":"要被清空的账号的appid"} 注意事项:

  1. access_token 需与被清空的账号类型一致:清第三方平台用 component_access_token, 代公众号/小程序清则用 authorizer_access_token
  2. 每个账号每月共 10 次清零机会

type Client

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

Client API客户端

func NewClient deprecated

func NewClient(config *Config, opt ...any) *Client

NewClient 创建新的API客户端(使用默认文件存储)

Deprecated: 配置或存储非法时会直接 log.Panic 终止进程,依赖库不应越权决定宿主进程生死。 请改用 NewClientE。

func NewClientE added in v0.1.3

func NewClientE(config *Config, opt ...any) (*Client, error)

NewClientE 创建新的API客户端(使用默认文件存储),出错时返回 error 而不是 panic @param config *Config 开放平台配置信息 @param opt ...any 可选参数,支持以下类型:

  • debugger.LoggerInterface: 自定义日志器
  • HTTPClient: 自定义HTTP客户端
  • EventHandler: 自定义事件处理器
  • EventErrorCallback: 事件处理异常回调(可选,用于上层落盘排障)

@return *Client API客户端实例 @return error 文件存储创建失败或配置校验失败时返回错误

func NewClientWithStorage deprecated

func NewClientWithStorage(config *Config, tokenStorage storage.TokenStorage, opt ...any) *Client

NewClientWithStorage 创建新的API客户端(使用自定义存储)

Deprecated: 配置非法时会直接 log.Panic 终止进程,请改用 NewClientWithStorageE。

func NewClientWithStorageE added in v0.1.3

func NewClientWithStorageE(config *Config, tokenStorage storage.TokenStorage, opt ...any) (*Client, error)

NewClientWithStorageE 创建新的API客户端(使用自定义存储),出错时返回 error 而不是 panic

func (*Client) AddToTemplate

func (c *Client) AddToTemplate(ctx context.Context, draftID int64, templateType int) (*core.APIResponse, error)

AddToTemplate 将草稿添加到模板库

func (*Client) ClearAuthorizerQuota added in v0.1.2

func (c *Client) ClearAuthorizerQuota(ctx context.Context, authorizerAppID string) (*core.APIResponse, error)

ClearAuthorizerQuota 代授权方(公众号/小程序)重置API调用次数 注意事项:代商家清除 quota 必须使用 authorizer_access_token,且消耗的是授权方自身的清零机会

func (*Client) ClearAuthorizerQuotaBySecret added in v0.1.2

func (c *Client) ClearAuthorizerQuotaBySecret(ctx context.Context, authorizerAppID string) (*core.APIResponse, error)

ClearAuthorizerQuotaBySecret 使用AppSecret代授权方(公众号/小程序)重置API调用次数 该接口通过 appsecret 调用,可在授权方 access_token 已耗尽时使用,appid 必须是已授权的账号

func (*Client) ClearComponentQuota

func (c *Client) ClearComponentQuota(ctx context.Context) (*core.APIResponse, error)

ClearComponentQuota 使用AppSecret重置第三方平台自身API调用次数 参考文档:https://developers.weixin.qq.com/doc/oplatform/openApi/openapi/api_componentclearquota_v2.html 注意事项:

  1. 该接口无 query 参数,仅支持 POST,路径为 /cgi-bin/component/clear_quota/v2
  2. 请求体字段为 appsecret(不是 component_appsecret)
  3. 与 clear_quota 共用每月10次清零机会

func (*Client) ClearQuota

func (c *Client) ClearQuota(ctx context.Context) (*core.APIResponse, error)

ClearQuota 重置第三方平台自身的API调用次数 参考文档:https://developers.weixin.qq.com/doc/service/api/apimanage/api_clearquota.html 注意事项:清第三方平台自身quota需用 component_access_token,每个账号每月共10次机会

func (*Client) CommitWxaCode added in v0.2.0

func (c *Client) CommitWxaCode(ctx context.Context, authorizerAppID string, req *CommitWxaCodeRequest) (*core.APIResponse, error)

CommitWxaCode 为已授权的小程序上传代码并生成体验版

参数:

  • ctx: 上下文
  • authorizerAppID: 授权方小程序 AppID
  • req: 上传代码请求参数

返回:

  • *core.APIResponse: 接口响应(errcode=0 表示成功)
  • error: 请求失败或微信返回错误时返回错误

使用示例:

err := openPlatformClient.CommitWxaCode(ctx, authorizerAppID, &openplatform.CommitWxaCodeRequest{
	TemplateID:  "12",
	ExtJSON:     `{"extAppid":"wx123","ext":{"attr1":"v1"}}`,
	UserVersion: "V1.0",
	UserDesc:    "首个版本",
})

文档:

func (*Client) DecryptMessage

func (c *Client) DecryptMessage(encryptedMsg, msgSignature, timestamp, nonce string) ([]byte, error)

DecryptMessage 解密消息(用于处理加密的授权事件)

使用带存储的加解密实例:密钥轮换过渡期会自动降级尝试存储中的上一次密钥(PrevKey)

func (*Client) DeleteTemplate

func (c *Client) DeleteTemplate(ctx context.Context, templateID int64) (*core.APIResponse, error)

DeleteTemplate 删除代码模板

func (*Client) GenerateAuthURL

func (c *Client) GenerateAuthURL(preAuthCode string, authType int, bizAppID string, platform string) string

GenerateAuthURL 生成授权链接 authType: 授权类型 (1:手机端仅展示公众号, 2:仅展示小程序, 3:公众号和小程序都展示, 4:小程序推客账号, 5:视频号账号, 6:全部, 8:带货助手账号) platform: 平台类型 ("pc": PC端, "mobile": 移动端)

func (*Client) GenerateMobileAuthURL

func (c *Client) GenerateMobileAuthURL(preAuthCode string, authType int, bizAppID string) string

GenerateMobileAuthURL 生成移动端授权链接

func (*Client) GeneratePcAuthURL

func (c *Client) GeneratePcAuthURL(preAuthCode string, authType int, bizAppID string) string

GeneratePcAuthURL 生成PC端授权链接

func (*Client) GetAllAuthorizers

func (c *Client) GetAllAuthorizers(ctx context.Context) (allAuthorizers []struct {
	AuthorizerAppID string `json:"authorizer_appid"`
	RefreshToken    string `json:"refresh_token,omitempty"` // 虽然文档写了,但是实际上获取不到
	AuthTime        int64  `json:"auth_time"`
}, err error)

GetAllAuthorizers 获取所有授权方列表,自动处理分页 该方法会循环调用GetAuthorizerList,直到获取所有授权方数据 返回所有授权方信息的切片和可能的错误

func (*Client) GetApiQuota

func (c *Client) GetApiQuota(ctx context.Context, authorizerAppID string) (*GetApiQuotaResponse, error)

GetApiQuota 查询API调用额度 authorizerAppID 为空时查询第三方平台自身额度(component_access_token), 非空时查询授权方额度(authorizer_access_token) 参考文档:https://developers.weixin.qq.com/doc/service/api/apimanage/api_quota_get.html

func (*Client) GetAuthorizerAccessToken

func (c *Client) GetAuthorizerAccessToken(ctx context.Context, authorizerAppID string) (string, error)

GetAuthorizerAccessToken 获取授权方access_token

func (*Client) GetAuthorizerInfo

func (c *Client) GetAuthorizerInfo(ctx context.Context, authorizerAppID string) (*GetAuthorizerInfoResponse, error)

GetAuthorizerInfo 获取授权方信息

func (*Client) GetAuthorizerList

func (c *Client) GetAuthorizerList(ctx context.Context, offset, count int) (*GetAuthorizerListResponse, error)

GetAuthorizerList 获取授权方列表

func (*Client) GetAuthorizerOption

func (c *Client) GetAuthorizerOption(ctx context.Context, authorizerAppID, optionName string) (*GetAuthorizerOptionResponse, error)

GetAuthorizerOption 获取授权方选项信息

func (*Client) GetComponentAccessToken

func (c *Client) GetComponentAccessToken(ctx context.Context, verifyTicket string) (*storage.ComponentAccessToken, error)

GetComponentAccessToken 获取第三方平台access_token

func (*Client) GetComponentToken

func (c *Client) GetComponentToken(ctx context.Context) (*storage.ComponentAccessToken, error)

GetComponentToken 获取开放平台令牌 @param ctx context.Context 上下文 @return *storage.ComponentAccessToken 组件访问令牌,包含令牌内容和有效期信息 @return error 错误信息,如果令牌获取失败或自动刷新失败则返回错误

func (*Client) GetComponentVerifyTicket

func (c *Client) GetComponentVerifyTicket(ctx context.Context) (*storage.ComponentVerifyTicket, error)

GetComponentVerifyTicket 获取验证票据 @param ctx context.Context 上下文 @return *storage.ComponentVerifyTicket 验证票据结构,包含票据内容和有效期信息 @return error 错误信息

func (*Client) GetConfig

func (c *Client) GetConfig() *Config

GetConfig 获取配置信息

func (*Client) GetEventHandler

func (c *Client) GetEventHandler() EventHandler

GetEventHandler 获取事件处理器

func (*Client) GetLogger

func (c *Client) GetLogger() logger.LoggerInterface

GetLogger 获取日志器

func (*Client) GetPreAuthCode

func (c *Client) GetPreAuthCode(ctx context.Context) (*storage.PreAuthCode, error)

GetPreAuthCode 获取预授权码(优先复用缓存,临近过期自动重新获取)

复用策略:先读存储,取到且未过期(留 60 秒安全余量)则直接返回, 避免每次都调微信API;否则调用微信API获取新预授权码并写回存储

func (*Client) GetPreAuthCodeFromAPI

func (c *Client) GetPreAuthCodeFromAPI(ctx context.Context) (*PreAuthCodeResponse, error)

GetPreAuthCodeFromAPI 从微信API获取预授权码

func (*Client) GetRidInfo

func (c *Client) GetRidInfo(ctx context.Context, rid string) (*GetRidInfoResponse, error)

GetRidInfo 查询rid信息

func (*Client) GetTemplateDraftList

func (c *Client) GetTemplateDraftList(ctx context.Context) (*GetTemplateDraftListResponse, error)

GetTemplateDraftList 获取草稿箱列表

func (*Client) GetTemplateList

func (c *Client) GetTemplateList(ctx context.Context) (*GetTemplateListResponse, error)

GetTemplateList 获取模板列表

func (*Client) GetWxaAuditStatus added in v0.2.0

func (c *Client) GetWxaAuditStatus(ctx context.Context, authorizerAppID string, auditID int64) (*GetWxaAuditStatusResponse, error)

GetWxaAuditStatus 查询指定发布审核单的审核状态

参数:

  • ctx: 上下文
  • authorizerAppID: 授权方小程序 AppID
  • auditID: 提交审核时获得的审核 id

返回:

  • *GetWxaAuditStatusResponse: Status 取值见 WxaAuditStatusXxx 常量
  • error: 请求失败或微信返回错误时返回错误

文档:

func (*Client) GetWxaCategory added in v0.2.0

func (c *Client) GetWxaCategory(ctx context.Context, authorizerAppID string) (*GetWxaCategoryResponse, error)

GetWxaCategory 获取审核时可填写的类目信息(已设置的二级类目及可选三级类目)

参数:

  • ctx: 上下文
  • authorizerAppID: 授权方小程序 AppID

返回:

  • *GetWxaCategoryResponse: 类目列表
  • error: 请求失败或微信返回错误时返回错误

文档:

func (*Client) GetWxaTrialQrcode added in v0.2.0

func (c *Client) GetWxaTrialQrcode(ctx context.Context, authorizerAppID, path string) (*WxaTrialQrcodeResponse, error)

GetWxaTrialQrcode 获取授权小程序的体验版二维码

参数:

  • ctx: 上下文
  • authorizerAppID: 授权方小程序 AppID
  • path: 扫码后进入的页面路径(可带参数,如 "page/index?action=1"),为空进入默认主页

返回:

  • *WxaTrialQrcodeResponse: Data 为图片二进制,可直接保存为图片
  • error: 请求失败或微信返回错误时返回错误

使用示例:

resp, err := openPlatformClient.GetWxaTrialQrcode(ctx, authorizerAppID, "pages/index/index")
if err == nil { os.WriteFile("trial.jpg", resp.Data, 0644) }

文档:

func (*Client) HandleAuthorizationEvent

func (c *Client) HandleAuthorizationEvent(ctx context.Context, xmlData []byte, msgSignature, timestamp, nonce, encryptType string) (string, error)

HandleAuthorizationEvent 处理微信开放平台授权事件 支持明文和加密两种消息格式 根据微信官方文档<mcreference link="https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Before_Develop/authorize_event.html" index="0">0</mcreference>, 接收POST请求后只需直接返回字符串"success"

func (*Client) ModifyWxaJumpDomain added in v0.2.0

func (c *Client) ModifyWxaJumpDomain(ctx context.Context, req *ModifyWxaJumpDomainRequest) (*ModifyWxaJumpDomainResponse, error)

ModifyWxaJumpDomain 设置第三方平台自身的小程序业务域名

参数:

  • ctx: 上下文
  • req: 请求参数(action=add/delete/set/get)

返回:

  • *ModifyWxaJumpDomainResponse: 各版本生效域名与未通过验证的域名
  • error: 请求失败或微信返回错误时返回错误

使用示例:

resp, err := openPlatformClient.ModifyWxaJumpDomain(ctx, &openplatform.ModifyWxaJumpDomainRequest{
	Action:          openplatform.DomainActionSet,
	WxaJumpH5Domain: "www.qq.com;wx.qq.com",
})

文档:

func (*Client) ModifyWxaServerDomain added in v0.2.0

ModifyWxaServerDomain 设置第三方平台自身的小程序服务器域名

授权给第三方代开发的小程序,其服务器域名只能为第三方平台配置的域名; 代小程序发布代码之前需先通过本接口配置平台自身域名。

参数:

  • ctx: 上下文
  • req: 请求参数(action=add/delete/set/get)

返回:

  • *ModifyWxaServerDomainResponse: 各版本生效域名与未通过验证的域名
  • error: 请求失败或微信返回错误时返回错误

使用示例:

resp, err := openPlatformClient.ModifyWxaServerDomain(ctx, &openplatform.ModifyWxaServerDomainRequest{
	Action:          openplatform.DomainActionSet,
	WxaServerDomain: "www.qq.com;wx.qq.com",
})

文档:

func (*Client) QueryAuth

func (c *Client) QueryAuth(ctx context.Context, authorizationCode string) (*QueryAuthResponse, error)

QueryAuth 使用授权码换取授权信息

func (*Client) RefreshAuthorizerToken

func (c *Client) RefreshAuthorizerToken(ctx context.Context, authorizerAppID, refreshToken string) (*AuthorizationInfo, error)

RefreshAuthorizerToken 刷新授权方access_token

func (*Client) ReleaseWxaCode added in v0.2.0

func (c *Client) ReleaseWxaCode(ctx context.Context, authorizerAppID string) (*core.APIResponse, error)

ReleaseWxaCode 发布最后一个审核通过的小程序代码版本

参数:

  • ctx: 上下文
  • authorizerAppID: 授权方小程序 AppID

返回:

  • *core.APIResponse: 接口响应
  • error: 请求失败或微信返回错误时返回错误

说明:

  • 官方要求 POST 必须携带空 JSON 对象 "{}",否则报 44002(empty post data)

文档:

func (*Client) RevertWxaCodeRelease added in v0.2.0

func (c *Client) RevertWxaCodeRelease(ctx context.Context, authorizerAppID, appVersion string) (*core.APIResponse, error)

RevertWxaCodeRelease 回退小程序线上版本

参数:

  • ctx: 上下文
  • authorizerAppID: 授权方小程序 AppID
  • appVersion: 目标版本号,为空时回滚到上一个线上版本

返回:

  • *core.APIResponse: 接口响应
  • error: 请求失败或微信返回错误时返回错误

说明:

  • 无上一个线上版本无法回退;最多保存最近发布/回退的 5 个版本;当前版本已回退过则不能再回退
  • 该接口为 GET 请求,版本号通过 query 参数 app_version 传递

文档:

func (*Client) SaveComponentVerifyTicket

func (c *Client) SaveComponentVerifyTicket(ctx context.Context, ticket string) error

SaveComponentVerifyTicket 保存验证票据 @param ctx context.Context 上下文 @param ticket string 票据内容 @return error 错误信息

func (*Client) SetAuthorizerOption

func (c *Client) SetAuthorizerOption(ctx context.Context, authorizerAppID, optionName, optionValue string) (*core.APIResponse, error)

SetAuthorizerOption 设置授权方选项信息

func (*Client) SetAuthorizerToken

func (c *Client) SetAuthorizerToken(authorizerAppID, accessToken, refreshToken string, expiresIn int) error

SetAuthorizerToken 设置授权方token信息

func (*Client) SetComponentToken

func (c *Client) SetComponentToken(token *storage.ComponentAccessToken) error

SetComponentToken 设置开放平台令牌

func (*Client) SetEventErrorCallback added in v0.2.0

func (c *Client) SetEventErrorCallback(cb EventErrorCallback)

SetEventErrorCallback 设置事件处理异常回调(可选)

参数:

  • cb EventErrorCallback 事件处理异常回调;事件解析/解密/验签失败或处理器返回错误时被同步调用, 不影响微信官方要求的「返回 success」行为

func (*Client) SetEventHandler

func (c *Client) SetEventHandler(handler EventHandler)

SetEventHandler 设置事件处理器

func (*Client) SetHTTPClient

func (c *Client) SetHTTPClient(client core.HTTPClient)

SetHTTPClient 设置自定义HTTP客户端

func (*Client) SetLogger

func (c *Client) SetLogger(log any)

SetLogger 设置日志器

func (*Client) SetPreAuthCode

func (c *Client) SetPreAuthCode(ctx context.Context, preAuthCode *storage.PreAuthCode) error

SetPreAuthCode 设置预授权码

func (*Client) StartPushTicket added in v0.2.0

func (c *Client) StartPushTicket(ctx context.Context) (*core.APIResponse, error)

StartPushTicket 启动 component_verify_ticket 推送服务

参数:

  • ctx: 上下文

返回:

  • *core.APIResponse: 接口响应(errcode=0 表示已启动或本来就处于正常状态 "in a normal state")
  • error: 请求失败或微信返回错误时返回错误

说明:

  • 用于第三方平台错过 ticket 推送或推送异常后的主动恢复
  • 新版官方文档明确该接口无 query 参数,凭证信息全部通过请求体传递

使用示例:

resp, err := openPlatformClient.StartPushTicket(ctx)

文档:

func (*Client) SubmitWxaAudit added in v0.2.0

func (c *Client) SubmitWxaAudit(ctx context.Context, authorizerAppID string, req *SubmitWxaAuditRequest) (*SubmitWxaAuditResponse, error)

SubmitWxaAudit 将上传的代码提交审核

参数:

  • ctx: 上下文
  • authorizerAppID: 授权方小程序 AppID
  • req: 提审请求参数(item_list 1-5 项,类目来自 GetWxaCategory)

返回:

  • *SubmitWxaAuditResponse: 含审核编号 auditid
  • error: 请求失败或微信返回错误时返回错误

文档:

func (*Client) UploadWxaAuditMedia added in v0.2.0

func (c *Client) UploadWxaAuditMedia(ctx context.Context, authorizerAppID, filename string, media []byte) (*UploadWxaAuditMediaResponse, error)

UploadWxaAuditMedia 上传提审素材(小程序页面截图/操作录屏),返回的 mediaid 用于提审 preview_info

参数:

  • ctx: 上下文
  • authorizerAppID: 授权方小程序 AppID
  • filename: 文件名(用于 multipart 表单,如 "shot.png"/"demo.mp4")
  • media: 素材二进制内容(图片 2M:PNG/JPEG/JPG/GIF;视频 10MB:MP4)

返回:

  • *UploadWxaAuditMediaResponse: 含 mediaid(有效期 3 天)
  • error: 请求失败或微信返回错误时返回错误

文档:

type CommitWxaCodeRequest added in v0.2.0

type CommitWxaCodeRequest struct {
	TemplateID  string `json:"template_id"`  // 代码模板 ID(从代码模板列表获取)
	ExtJSON     string `json:"ext_json"`     // ext.json 配置内容(JSON 字符串,支持 extAppid/ext/extPages/pages/window 等)
	UserVersion string `json:"user_version"` // 代码版本号(长度不超过 64 字符)
	UserDesc    string `json:"user_desc"`    // 代码描述
}

CommitWxaCodeRequest 上传并发布小程序代码请求(POST /wxa/commit)

注意:

  • 提交成功后会同时生成体验版
  • 标准模板库的模板 ext_json 仅支持 {"extAppid":"", "ext": {}, "window": {}}

type ComponentTokenRequest

type ComponentTokenRequest struct {
	ComponentAppID        string `json:"component_appid"`
	ComponentAppSecret    string `json:"component_appsecret"`
	ComponentVerifyTicket string `json:"component_verify_ticket"`
}

ComponentTokenRequest 获取component_access_token请求参数

type ComponentVerifyTicketEvent

type ComponentVerifyTicketEvent struct {
	AuthorizationEvent
	ComponentVerifyTicket string `xml:"ComponentVerifyTicket" json:"component_verify_ticket"`
}

ComponentVerifyTicketEvent 验证票据推送事件 InfoType: component_verify_ticket 微信服务器每隔10分钟推送component_verify_ticket到第三方平台的消息接收URL 根据微信官方文档<mcreference link="https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Before_Develop/component_verify_ticket.html" index="0">0</mcreference>, 接收POST请求后只需直接返回字符串"success"

type ConditionalMenu

type ConditionalMenu struct {
	Button    []Button `json:"button"`
	MatchRule struct {
		TagID              string `json:"tag_id,omitempty"`
		Sex                string `json:"sex,omitempty"`
		Country            string `json:"country,omitempty"`
		Province           string `json:"province,omitempty"`
		City               string `json:"city,omitempty"`
		ClientPlatformType string `json:"client_platform_type,omitempty"`
		Language           string `json:"language,omitempty"`
	} `json:"matchrule"`
}

ConditionalMenu 个性化菜单

type Config

type Config struct {
	ComponentAppID     string `json:"component_appid" ini:"component_appid"`         // 第三方平台appid
	ComponentAppSecret string `json:"component_appsecret" ini:"component_appsecret"` // 第三方平台appsecret
	ComponentToken     string `json:"component_token" ini:"component_token"`         // 消息校验Token
	EncodingAESKey     string `json:"encoding_aes_key" ini:"encoding_aes_key"`       // 消息加解密Key
	RedirectURI        string `json:"redirect_uri" ini:"redirect_uri"`               // 授权回调URI
}

Config 微信开放平台配置结构体

func (*Config) Validate

func (c *Config) Validate() error

Validate 验证配置的有效性

type ConfirmInfo

type ConfirmInfo struct {
	NeedConfirm    int `json:"need_confirm"`
	AlreadyConfirm int `json:"already_confirm"`
	CanConfirm     int `json:"can_confirm"`
}

type DefaultEventHandler

type DefaultEventHandler struct{}

DefaultEventHandler 默认事件处理器

func (*DefaultEventHandler) HandleAuthorized

func (h *DefaultEventHandler) HandleAuthorized(ctx context.Context, event *AuthorizedEvent) error

func (*DefaultEventHandler) HandleComponentVerifyTicket

func (h *DefaultEventHandler) HandleComponentVerifyTicket(ctx context.Context, event *ComponentVerifyTicketEvent) error

func (*DefaultEventHandler) HandleEncodingAESKeyChanged

func (h *DefaultEventHandler) HandleEncodingAESKeyChanged(ctx context.Context, event *EncodingAESKeyChangedEvent) error

func (*DefaultEventHandler) HandleUnauthorized

func (h *DefaultEventHandler) HandleUnauthorized(ctx context.Context, event *UnauthorizedEvent) error

func (*DefaultEventHandler) HandleUpdateAuthorized

func (h *DefaultEventHandler) HandleUpdateAuthorized(ctx context.Context, event *UpdateAuthorizedEvent) error

type DeleteTemplateRequest

type DeleteTemplateRequest struct {
	TemplateID int64 `json:"template_id"`
}

DeleteTemplateRequest 删除代码模板请求

type EncodingAESKeyChangedEvent

type EncodingAESKeyChangedEvent struct {
	AuthorizationEvent
	NewEncodingAESKey string `xml:"NewEncodingAESKey" json:"new_encoding_aes_key"`
}

EncodingAESKeyChangedEvent EncodingAESKey变更事件 InfoType: encoding_aes_key_changed 当第三方平台在微信开放平台后台修改EncodingAESKey时,微信服务器会推送此事件 根据微信官方规范<mcreference link="https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Before_Develop/Message_encryption_and_decryption.html" index="1">1</mcreference>, 需要保存上一次的EncodingAESKey以确保平滑过渡

type EventErrorCallback added in v0.2.0

type EventErrorCallback func(source string, err error)

EventErrorCallback 开放平台事件处理异常回调。 当授权事件解析/解密/验签失败、票据存储失败或事件处理器返回错误时被同步调用, 用于上层落盘排障;不影响微信官方要求的「返回 success」行为。 不设置则维持原行为(仅记录日志)。

参数 source 为失败环节标识,当前取值:

  • "parse_encrypted_xml" / "decrypt":加密消息解析或解密失败
  • "parse_event_xml" / "validate_event":事件 XML 解析或验签失败
  • "parse_<事件类型>_event" / "handle_<事件类型>":具体事件的解析或处理器执行失败 (事件类型:authorized / unauthorized / updateauthorized / component_verify_ticket / encoding_aes_key_changed)
  • "save_component_verify_ticket" / "set_prev_encoding_aes_key":票据存储、历史密钥保存失败

使用示例:

openplatform.NewClientE(cfg, func(source string, err error) {
    // 落盘/告警等排障处理
})

type EventHandler

type EventHandler interface {
	// HandleAuthorized 处理授权成功事件
	HandleAuthorized(ctx context.Context, event *AuthorizedEvent) error

	// HandleUnauthorized 处理取消授权事件
	HandleUnauthorized(ctx context.Context, event *UnauthorizedEvent) error

	// HandleUpdateAuthorized 处理授权更新事件
	HandleUpdateAuthorized(ctx context.Context, event *UpdateAuthorizedEvent) error

	// HandleComponentVerifyTicket 处理验证票据推送事件
	// 根据微信官方文档<mcreference link="https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Before_Develop/component_verify_ticket.html" index="0">0</mcreference>,
	// 接收POST请求后只需直接返回字符串"success"
	HandleComponentVerifyTicket(ctx context.Context, event *ComponentVerifyTicketEvent) error

	// HandleEncodingAESKeyChanged 处理EncodingAESKey变更事件
	// 当第三方平台在微信开放平台后台修改EncodingAESKey时,微信服务器会推送此事件
	// 根据微信官方规范<mcreference link="https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Before_Develop/Message_encryption_and_decryption.html" index="1">1</mcreference>,
	// 需要保存上一次的EncodingAESKey以确保平滑过渡
	HandleEncodingAESKeyChanged(ctx context.Context, event *EncodingAESKeyChangedEvent) error
}

EventHandler 事件处理器接口

type FuncInfo

type FuncInfo struct {
	FuncScopeCategory FuncScopeCategory `json:"funcscope_category"`
	ConfirmInfo       ConfirmInfo       `json:"confirm_info,omitempty"`
}

type FuncScopeCategory

type FuncScopeCategory struct {
	Id int `json:"id"`
}

FuncScopeCategory 授权给开发者的权限集

type GetApiQuotaRequest

type GetApiQuotaRequest struct {
	AppID string `json:"appid"` // 要查询的账号的appid
}

GetApiQuotaRequest 查询API调用额度请求 参考文档:https://developers.weixin.qq.com/doc/service/api/apimanage/api_quota_get.html 接口说明:POST https://api.weixin.qq.com/cgi-bin/openapi/quota/get?access_token=ACCESS_TOKEN 请求体同样只有 {"appid":"..."}

type GetApiQuotaResponse

type GetApiQuotaResponse struct {
	core.APIResponse
	Quota []QuotaItem `json:"quota"`
}

GetApiQuotaResponse 查询API调用额度响应

type GetAuthorizerInfoRequest

type GetAuthorizerInfoRequest struct {
	ComponentAppID  string `json:"component_appid"`
	AuthorizerAppID string `json:"authorizer_appid"`
}

GetAuthorizerInfoRequest 获取授权方信息请求参数

type GetAuthorizerInfoResponse

type GetAuthorizerInfoResponse struct {
	core.APIResponse
	AuthorizerInfo AuthorizerInfo `json:"authorizer_info"`
}

GetAuthorizerInfoResponse 授权方信息响应

type GetAuthorizerListRequest

type GetAuthorizerListRequest struct {
	ComponentAppID string `json:"component_appid"`
	Offset         int    `json:"offset"`
	Count          int    `json:"count"`
}

GetAuthorizerListRequest 获取授权方列表请求参数

type GetAuthorizerListResponse

type GetAuthorizerListResponse struct {
	core.APIResponse
	TotalCount int `json:"total_count"`
	List       []struct {
		AuthorizerAppID string `json:"authorizer_appid"`
		RefreshToken    string `json:"refresh_token,omitempty"` // 虽然文档写了,但是实际上获取不到
		AuthTime        int64  `json:"auth_time"`
	} `json:"list"`
}

GetAuthorizerListResponse 获取授权方列表响应

type GetAuthorizerOptionRequest

type GetAuthorizerOptionRequest struct {
	ComponentAppID  string `json:"component_appid"`
	AuthorizerAppID string `json:"authorizer_appid"`
	OptionName      string `json:"option_name"`
}

GetAuthorizerOptionRequest 获取授权方选项信息请求

type GetAuthorizerOptionResponse

type GetAuthorizerOptionResponse struct {
	core.APIResponse
	AuthorizerAppID string `json:"authorizer_appid"`
	OptionName      string `json:"option_name"`
	OptionValue     string `json:"option_value"`
}

GetAuthorizerOptionResponse 获取授权方选项信息响应

type GetRidInfoRequest

type GetRidInfoRequest struct {
	RID string `json:"rid"`
}

GetRidInfoRequest 查询rid信息请求

type GetRidInfoResponse

type GetRidInfoResponse struct {
	core.APIResponse
	RidInfo RidInfo `json:"rid_info"`
}

GetRidInfoResponse 查询rid信息响应

type GetTemplateDraftListResponse

type GetTemplateDraftListResponse struct {
	core.APIResponse
	DraftList []TemplateDraft `json:"draft_list"`
}

GetTemplateDraftListResponse 获取草稿箱列表响应

type GetTemplateListResponse

type GetTemplateListResponse struct {
	core.APIResponse
	TemplateList []Template `json:"template_list"`
}

GetTemplateListResponse 获取模板列表响应

type GetWxaAuditStatusRequest added in v0.2.0

type GetWxaAuditStatusRequest struct {
	AuditID int64 `json:"auditid"` // 提交审核时获得的审核 id
}

GetWxaAuditStatusRequest 查询审核状态请求(POST /wxa/get_auditstatus)

type GetWxaAuditStatusResponse added in v0.2.0

type GetWxaAuditStatusResponse struct {
	core.APIResponse
	Status     int    `json:"status"`               // 审核状态:0成功/1拒绝/2审核中/3已撤回/4延后
	Reason     string `json:"reason,omitempty"`     // status=1 拒绝原因;status=4 延后原因
	Screenshot string `json:"screenshot,omitempty"` // status=1 时审核失败截图,用 | 分隔的 media_id 列表
}

GetWxaAuditStatusResponse 查询审核状态响应

type GetWxaCategoryResponse added in v0.2.0

type GetWxaCategoryResponse struct {
	core.APIResponse
	CategoryList []WxaCategory `json:"category_list"` // 已设置的二级类目及可选三级类目列表
}

GetWxaCategoryResponse 获取审核时可填写的类目信息响应(GET /wxa/get_category)

type ImageMessage

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

ImageMessage 图片消息

type JSSDKCacher

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

JSSDKCacher JS-SDK配置缓存器

func (*JSSDKCacher) CacheConfig

func (c *JSSDKCacher) CacheConfig(url string, jsAPIList []string, config *JSSDKConfig)

CacheConfig 缓存JS-SDK配置 - 带统计功能

func (*JSSDKCacher) CleanupExpired added in v0.0.5

func (c *JSSDKCacher) CleanupExpired()

CleanupExpired 清理过期缓存

func (*JSSDKCacher) GetCachedConfig

func (c *JSSDKCacher) GetCachedConfig(url string, jsAPIList []string) (*JSSDKConfig, error)

GetCachedConfig 获取缓存的JS-SDK配置 - 带统计功能

func (*JSSDKCacher) GetStats added in v0.0.5

func (c *JSSDKCacher) GetStats() CacheStats

GetStats 获取缓存统计信息

type JSSDKConfig

type JSSDKConfig struct {
	AppID     string   `json:"appId" ini:"app_id"`          // 公众号appid
	Timestamp int64    `json:"timestamp" ini:"timestamp"`   // 时间戳
	NonceStr  string   `json:"nonceStr" ini:"nonce_str"`    // 随机字符串
	Signature string   `json:"signature" ini:"signature"`   // 签名
	JSAPIList []string `json:"jsApiList" ini:"js_api_list"` // JS-SDK调用权限列表
	// contains filtered or unexported fields
}

JSSDKConfig JS-SDK配置结构

type JSSDKManager

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

JSSDKManager JS-SDK管理器

func (*JSSDKManager) GetConfig

func (jm *JSSDKManager) GetConfig(ctx context.Context, url string, jsAPIList []string) (*JSSDKConfig, error)

GetConfig 生成JS-SDK配置

func (*JSSDKManager) GetConfigOptimized

func (jm *JSSDKManager) GetConfigOptimized(ctx context.Context, url string, jsAPIList []string) (*JSSDKConfig, error)

GetConfigOptimized 优化后的JS-SDK配置获取

func (*JSSDKManager) GetConfigWithRetry

func (jm *JSSDKManager) GetConfigWithRetry(ctx context.Context, url string, jsAPIList []string, maxRetries int) (*JSSDKConfig, error)

GetConfigWithRetry 带重试的JS-SDK配置获取

type MediaResponse

type MediaResponse struct {
	core.APIResponse
	Type      string `json:"type"`
	MediaID   string `json:"media_id"`
	CreatedAt int64  `json:"created_at"`
}

MediaResponse 媒体文件响应

type Menu struct {
	Button []Button `json:"button"`
}

Menu 菜单结构

type MiniProgramClient

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

MiniProgramClient 小程序客户端

func (*MiniProgramClient) GetWXACode

func (mpc *MiniProgramClient) GetWXACode(ctx context.Context, request *WXACodeRequest) (*WXACodeResponse, error)

GetWXACode 获取小程序码

参数:

  • ctx: 上下文
  • request: 小程序码请求(Path 必填)

返回:

  • *WXACodeResponse: 成功时 Buffer 为图片二进制,可直接保存为图片
  • error: 请求失败或微信返回错误时返回错误

说明:

  • 官方接口成功时返回图片二进制、失败时才返回 JSON,因此必须走 MakeRaw 并按 Content-Type 分流,不能当作普通 JSON 接口解析

type MiniProgramInfo

type MiniProgramInfo struct {
	Network     NetworkInfo `json:"network"`
	Categories  []Category  `json:"categories"`
	VisitStatus int         `json:"visit_status"`
}

MiniProgramInfo 小程序信息

type ModifyWxaJumpDomainRequest added in v0.2.0

type ModifyWxaJumpDomainRequest struct {
	Action                    string `json:"action"`                                 // 操作类型:add/delete/set/get
	WxaJumpH5Domain           string `json:"wxa_jump_h5_domain,omitempty"`           // 业务域名列表(; 分隔)
	IsModifyPublishedTogether *bool  `json:"is_modify_published_together,omitempty"` // 是否同时修改"全网发布版"(默认 false 只改测试版)
}

ModifyWxaJumpDomainRequest 设置第三方平台小程序业务域名请求

注意:

  • 配置前需将校验文件放置在域名根目录(校验文件需先通过官方 get_domain_confirmfile 接口获取)
  • 域名最多 200 个,以 ; 隔开;不带协议头与 URI 路径
  • action=get 时无需传域名字段

type ModifyWxaJumpDomainResponse added in v0.2.0

type ModifyWxaJumpDomainResponse struct {
	core.APIResponse
	PublishedWxaJumpH5Domain string `json:"published_wxa_jump_h5_domain,omitempty"` // 生效的"全网发布版"业务域名
	TestingWxaJumpH5Domain   string `json:"testing_wxa_jump_h5_domain,omitempty"`   // 生效的"测试版"业务域名
	InvalidWxaJumpH5Domain   string `json:"invalid_wxa_jump_h5_domain,omitempty"`   // 未通过验证的域名
}

ModifyWxaJumpDomainResponse 设置第三方平台小程序业务域名响应

type ModifyWxaServerDomainRequest added in v0.2.0

type ModifyWxaServerDomainRequest struct {
	Action                    string `json:"action"`                                 // 操作类型:add/delete/set/get
	WxaServerDomain           string `json:"wxa_server_domain,omitempty"`            // 服务器域名列表(; 分隔)
	IsModifyPublishedTogether *bool  `json:"is_modify_published_together,omitempty"` // 是否同时修改"全网发布版"(默认 false 只改测试版)
}

ModifyWxaServerDomainRequest 设置第三方平台小程序服务器域名请求

注意:

  • 每月只可修改申请 50 次
  • 域名最多 1000 个,以 ; 隔开;不带 http:// 协议头,不带 URI 路径,如 "www.qq.com;wx.qq.com"
  • action=get 时无需传域名字段

type ModifyWxaServerDomainResponse added in v0.2.0

type ModifyWxaServerDomainResponse struct {
	core.APIResponse
	PublishedWxaServerDomain string `json:"published_wxa_server_domain,omitempty"` // 生效的"全网发布版"域名(修改失败或无已发布平台时不返回)
	TestingWxaServerDomain   string `json:"testing_wxa_server_domain,omitempty"`   // 生效的"测试版"域名
	InvalidWxaServerDomain   string `json:"invalid_wxa_server_domain,omitempty"`   // 未通过验证的域名
}

ModifyWxaServerDomainResponse 设置第三方平台小程序服务器域名响应

type MusicMessage

type MusicMessage struct {
	Title        string `json:"title"`
	Description  string `json:"description"`
	MusicURL     string `json:"musicurl"`
	HQMusicURL   string `json:"hqmusicurl"`
	ThumbMediaID string `json:"thumb_media_id"`
}

MusicMessage 音乐消息

type NetworkInfo

type NetworkInfo struct {
	// 以下字段官方返回的 JSON 键均为首字母大写(微信历史原因),请勿改为下划线/小写,否则解析不到
	RequestDomain   []string `json:"RequestDomain"`
	WsRequestDomain []string `json:"WsRequestDomain"`
	UploadDomain    []string `json:"UploadDomain"`
	DownloadDomain  []string `json:"DownloadDomain"`
	BizDomain       []string `json:"BizDomain"`
	UDPDomain       []string `json:"UDPDomain"`
}

NetworkInfo 网络信息

type NewsMessage

type NewsMessage struct {
	Articles []Article `json:"articles"`
}

NewsMessage 图文消息

type OAuthClient

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

OAuthClient 网页授权客户端

func (*OAuthClient) GetAccessToken

func (oc *OAuthClient) GetAccessToken(ctx context.Context, code string) (*OAuthToken, error)

GetAccessToken 使用授权码获取AccessToken

func (*OAuthClient) GetAuthorizeURL deprecated

func (oc *OAuthClient) GetAuthorizeURL(opts ...string) string

GetAuthorizeURL 生成授权页面URL

  • opts -- scope:授权类型,snsapi_base 静默授权,snsapi_userinfo 授权并获取用户信息 -- state:用于保持请求和回调的状态,授权请求后原样带回给第三方。 -- forcePopup 强制此次授权需要用户弹窗确认;默认为false;需要注意的是,若用户命中了特殊场景下的静默授权逻辑,则此参数不生效

Deprecated: 参数非法时会直接 panic 终止进程,请改用 GetAuthorizeURLE。

func (*OAuthClient) GetAuthorizeURLE added in v0.1.3

func (oc *OAuthClient) GetAuthorizeURLE(opts ...string) (string, error)

GetAuthorizeURLE 生成授权页面URL(E 版:参数非法时返回 error 而非 panic)

func (*OAuthClient) GetBaseAuthorizeURL

func (oc *OAuthClient) GetBaseAuthorizeURL(state string) string

GetBaseAuthorizeURL 生成静默授权URL Deprecated: 请改用 GetBaseAuthorizeURLE。

func (*OAuthClient) GetBaseAuthorizeURLE added in v0.1.3

func (oc *OAuthClient) GetBaseAuthorizeURLE(state string) (string, error)

GetBaseAuthorizeURLE 生成静默授权URL(E 版)

func (*OAuthClient) GetUserInfo

func (oc *OAuthClient) GetUserInfo(ctx context.Context, accessToken, openID string) (*official_account.OAuthUserInfoResponse, error)

GetUserInfo 获取用户信息

func (*OAuthClient) GetUserInfoAuthorizeURL

func (oc *OAuthClient) GetUserInfoAuthorizeURL(state string) string

GetUserInfoAuthorizeURL 生成用户信息授权URL Deprecated: 请改用 GetUserInfoAuthorizeURLE。

func (*OAuthClient) GetUserInfoAuthorizeURLE added in v0.1.3

func (oc *OAuthClient) GetUserInfoAuthorizeURLE(state string) (string, error)

GetUserInfoAuthorizeURLE 生成用户信息授权URL(E 版)

func (*OAuthClient) RefreshToken

func (oc *OAuthClient) RefreshToken(ctx context.Context, refreshToken string) (*OAuthToken, error)

RefreshToken 刷新AccessToken

type OAuthComponentRefreshTokenRequest

type OAuthComponentRefreshTokenRequest struct {
	ComponentAppID       string `json:"component_appid"`        // 第三方平台appid
	AppID                string `json:"appid"`                  // 授权公众号appid
	RefreshToken         string `json:"refresh_token"`          // 填写通过access_token获取到的refresh_token参数
	GrantType            string `json:"grant_type"`             // 填写为refresh_token
	ComponentAccessToken string `json:"component_access_token"` // 第三方平台component_access_token
}

OAuthComponentRefreshTokenRequest 第三方平台代公众号刷新网页授权access_token请求参数

type OAuthToken

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

OAuthToken 网页授权Token

type PreAuthCodeRequest

type PreAuthCodeRequest struct {
	ComponentAppID string `json:"component_appid"`
}

PreAuthCodeRequest 获取预授权码请求参数

type PreAuthCodeResponse

type PreAuthCodeResponse struct {
	core.APIResponse
	PreAuthCode string `json:"pre_auth_code"`
	ExpiresIn   int    `json:"expires_in"`
}

PreAuthCodeResponse 预授权码响应

type QueryAuthRequest

type QueryAuthRequest struct {
	ComponentAppID    string `json:"component_appid"`
	AuthorizationCode string `json:"authorization_code"`
}

QueryAuthRequest 使用授权码换取授权信息请求参数

type QueryAuthResponse

type QueryAuthResponse struct {
	core.APIResponse
	AuthorizationInfo AuthorizationInfo `json:"authorization_info"`
}

QueryAuthResponse 授权信息响应

type QuotaItem

type QuotaItem struct {
	API            string `json:"api"`
	DailyQuota     int    `json:"daily_quota"`
	DailyUsed      int    `json:"daily_used"`
	DailyRemaining int    `json:"daily_remaining"`
}

QuotaItem API调用额度项

type RidInfo

type RidInfo struct {
	Request struct {
		InvokeTime  string `json:"invoke_time"`
		CostInMs    int    `json:"cost_in_ms"`
		RequestURL  string `json:"request_url"`
		RequestBody string `json:"request_body"`
		Response    string `json:"response"`
		ClientIP    string `json:"client_ip"`
	} `json:"request"`
}

RidInfo rid信息

type ServiceTypeInfo

type ServiceTypeInfo struct {
	ID int `json:"id"`
}

ServiceTypeInfo 账号类型

type SetAuthorizerOptionRequest

type SetAuthorizerOptionRequest struct {
	ComponentAppID  string `json:"component_appid"`
	AuthorizerAppID string `json:"authorizer_appid"`
	OptionName      string `json:"option_name"`
	OptionValue     string `json:"option_value"`
}

SetAuthorizerOptionRequest 设置授权方选项信息请求

type StartPushTicketRequest added in v0.2.0

type StartPushTicketRequest struct {
	ComponentAppID  string `json:"component_appid"`  // 平台型第三方平台的 AppID
	ComponentSecret string `json:"component_secret"` // 平台型第三方平台的 APPSECRET
}

StartPushTicketRequest 启动票据推送服务请求

type SubmitWxaAuditRequest added in v0.2.0

type SubmitWxaAuditRequest struct {
	ItemList      []WxaAuditItem       `json:"item_list"`                // 审核项列表(1-5 项)
	PreviewInfo   *WxaAuditPreviewInfo `json:"preview_info,omitempty"`   // 预览信息
	VersionDesc   string               `json:"version_desc,omitempty"`   // 版本说明和功能解释
	FeedbackInfo  string               `json:"feedback_info,omitempty"`  // 反馈内容(至多 200 字,仅上次被驳回时生效)
	FeedbackStuff string               `json:"feedback_stuff,omitempty"` // 用 | 分割的 media_id 列表(至多 5 张)
	UGCDeclare    *WxaUGCDeclare       `json:"ugc_declare,omitempty"`    // UGC 信息安全声明
}

SubmitWxaAuditRequest 提交小程序代码审核请求(POST /wxa/submit_audit)

注意:

  • item_list 至多 5 项,类目必填且须为小程序已配置的类目
  • 仅上个版本被驳回时 feedback_info/feedback_stuff 才生效

type SubmitWxaAuditResponse added in v0.2.0

type SubmitWxaAuditResponse struct {
	core.APIResponse
	// AuditID 审核编号(查询审核状态时使用)
	// 官方参数表写 String、示例写数字,用 FlexString 双形态兼容,取值用 .String()/.Int64()
	AuditID core.FlexString `json:"auditid"`
}

SubmitWxaAuditResponse 提交审核响应

type Template

type Template struct {
	CreateTime  int64  `json:"create_time"`
	UserVersion string `json:"user_version"`
	UserDesc    string `json:"user_desc"`
	TemplateID  int64  `json:"template_id"`
}

Template 模板库模板

type TemplateDraft

type TemplateDraft struct {
	CreateTime  int64  `json:"create_time"`
	UserVersion string `json:"user_version"`
	UserDesc    string `json:"user_desc"`
	DraftID     int64  `json:"draft_id"`
}

TemplateDraft 草稿箱模板

type TextMessage

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

TextMessage 文本消息

type UnauthorizedEvent

type UnauthorizedEvent struct {
	AuthorizationEvent
}

UnauthorizedEvent 取消授权事件 InfoType: unauthorized 当公众号/服务号/小程序/微信小店/带货助手/视频号助手取消对第三方平台的授权时触发

type UpdateAuthorizedEvent

type UpdateAuthorizedEvent struct {
	AuthorizationEvent
}

UpdateAuthorizedEvent 授权更新事件 InfoType: updateauthorized 当授权方更新授权时触发。如果更新授权时,授权的权限集没有发生变化,将不会触发授权更新通知

type UploadWxaAuditMediaResponse added in v0.2.0

type UploadWxaAuditMediaResponse struct {
	core.APIResponse
	Type    string `json:"type"`    // 素材类型(image/video)
	MediaID string `json:"mediaid"` // 素材 mediaid(有效期 3 天,用于 preview_info)
}

UploadWxaAuditMediaResponse 提审素材上传响应(POST /wxa/uploadmedia,multipart)

type UserInfo

type UserInfo struct {
	core.APIResponse
	Subscribe      int    `json:"subscribe"`
	OpenID         string `json:"openid"`
	Nickname       string `json:"nickname"`
	Sex            int    `json:"sex"`
	Language       string `json:"language"`
	City           string `json:"city"`
	Province       string `json:"province"`
	Country        string `json:"country"`
	HeadImgURL     string `json:"headimgurl"`
	SubscribeTime  int64  `json:"subscribe_time"`
	UnionID        string `json:"unionid,omitempty"`
	Remark         string `json:"remark"`
	GroupID        int    `json:"groupid"`
	TagIDList      []int  `json:"tagid_list"`
	SubscribeScene string `json:"subscribe_scene"`
	QRScene        int    `json:"qr_scene"`
	QRSceneStr     string `json:"qr_scene_str"`
}

UserInfo 用户信息

type UserList

type UserList struct {
	core.APIResponse
	Total int `json:"total"`
	Count int `json:"count"`
	Data  struct {
		OpenID []string `json:"openid"`
	} `json:"data"`
	NextOpenID string `json:"next_openid"`
}

UserList 用户列表

type VerifyTypeInfo

type VerifyTypeInfo struct {
	ID int `json:"id"`
}

VerifyTypeInfo 认证类型

type VideoMessage

type VideoMessage struct {
	MediaID      string `json:"media_id"`
	ThumbMediaID string `json:"thumb_media_id"` // 视频缩略图的媒体ID(官方要求必填)
	Title        string `json:"title,omitempty"`
	Description  string `json:"description,omitempty"`
}

VideoMessage 视频消息

type VoiceMessage

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

VoiceMessage 语音消息

type WXACodeRequest

type WXACodeRequest struct {
	Path  string `json:"path"`
	Width int    `json:"width,omitempty"`
}

WXACodeRequest 小程序码请求

type WXACodeResponse

type WXACodeResponse struct {
	core.APIResponse
	ContentType string `json:"-"` // 图片 Content-Type(如 image/jpeg)
	Buffer      []byte `json:"-"` // 图片二进制数据
}

WXACodeResponse 获取小程序码响应

成功时 Buffer 为图片二进制数据、ContentType 为图片类型;失败时返回 core.APIResponse 错误。

type WxaAuditItem added in v0.2.0

type WxaAuditItem struct {
	Address     string `json:"address,omitempty"`     // 小程序页面路径(来自 get_page 接口)
	Tag         string `json:"tag,omitempty"`         // 标签(空格分隔,至多 10 个,单个长度至多 20)
	FirstClass  string `json:"first_class"`           // 一级类目名称(必填)
	SecondClass string `json:"second_class"`          // 二级类目名称(必填)
	ThirdClass  string `json:"third_class,omitempty"` // 三级类目名称
	FirstID     int64  `json:"first_id"`              // 一级类目 ID(必填)
	SecondID    int64  `json:"second_id"`             // 二级类目 ID(必填)
	ThirdID     int64  `json:"third_id,omitempty"`    // 三级类目 ID
	Title       string `json:"title,omitempty"`       // 页面标题(长度至多 32)
}

WxaAuditItem 提交审核的审核项

类目(first_class/second_class/third_class 及对应 ID)必须来自 GetWxaCategory 已配置的类目。

type WxaAuditPreviewInfo added in v0.2.0

type WxaAuditPreviewInfo struct {
	VideoIDList []string `json:"video_id_list,omitempty"` // 录屏 mediaid 列表
	PicIDList   []string `json:"pic_id_list,omitempty"`   // 截屏 mediaid 列表
}

WxaAuditPreviewInfo 提审预览信息(小程序页面截图和操作录屏,mediaid 来自 UploadWxaAuditMedia,有效期 3 天)

type WxaCategory added in v0.2.0

type WxaCategory struct {
	FirstClass  string `json:"first_class,omitempty"`  // 一级类目名称
	SecondClass string `json:"second_class,omitempty"` // 二级类目名称
	ThirdClass  string `json:"third_class,omitempty"`  // 三级类目名称(可选)
	FirstID     int64  `json:"first_id,omitempty"`     // 一级类目 ID
	SecondID    int64  `json:"second_id,omitempty"`    // 二级类目 ID
	ThirdID     int64  `json:"third_id,omitempty"`     // 三级类目 ID(可选)
}

WxaCategory 小程序类目信息(get_category 响应项,也是提审时 item_list 的类目来源)

type WxaTrialQrcodeResponse added in v0.2.0

type WxaTrialQrcodeResponse struct {
	core.APIResponse
	Data        []byte `json:"-"` // 图片二进制数据
	ContentType string `json:"-"` // 响应 Content-Type(如 image/jpeg)
}

WxaTrialQrcodeResponse 体验版二维码响应(GET /wxa/get_qrcode)

成功时 Data 为图片二进制(image/jpeg),可直接保存为图片;失败时微信返回 JSON 错误。

type WxaUGCDeclare added in v0.2.0

type WxaUGCDeclare struct {
	Scene          []int  `json:"scene,omitempty"`            // UGC 场景:0不涉及/1用户资料/2图片/3视频/4文本/5其他(可多选,填 0 时无需其他字段)
	OtherSceneDesc string `json:"other_scene_desc,omitempty"` // scene 选"其他"时的说明(不超 256 字)
	Method         []int  `json:"method,omitempty"`           // 内容安全机制:1平台API/2其他审核产品/3人工审核/4未做审核
	HasAuditTeam   int    `json:"has_audit_team,omitempty"`   // 是否有审核团队:0无/1有
	AuditDesc      string `json:"audit_desc,omitempty"`       // 审核机制说明(不超 256 字)
}

WxaUGCDeclare 用户生成内容(UGC)场景信息安全声明

当小程序第一次提交审核且类目包含社交-社区/论坛、社交-笔记、社交-问答其中之一时必填。

Jump to

Keyboard shortcuts

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