component

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeOK                 = 0
	ErrCodeInvalidCredential  = 40001 // access_token 过期错误码
	ErrCodeAccessTokenExpired = 42001 // access_token 过期错误码(maybe!!!)
)

Variables

This section is empty.

Functions

func AccountSetSignature

func AccountSetSignature(clt *core.Client, signature string) (err error)

func AuthH5Url

func AuthH5Url(appId, preAuthCode, redirectUri string, authType AuthType, bizAppId string) string

func AuthWebUrl

func AuthWebUrl(appId, preAuthCode, redirectURI string, authType AuthType, bizAppId string) string

AuthCodeURL 生成网页授权地址.

appId:       公众号的唯一标识
redirectURI: 授权后重定向的回调链接地址
scope:       应用授权作用域
state:       重定向后会带上 state 参数, 开发者可以填写 a-zA-Z0-9 的参数值, 最多128字节

func CheckWxVerifyNickname

func CheckWxVerifyNickname(clt *core.Client, nickname string) (hitCondition bool, wording string, err error)

func CreateOpenAndBind

func CreateOpenAndBind(clt *core.Client, appId string) (openAppId string, err error)

func CreatePreAuthCode

func CreatePreAuthCode(clt *core.Client, appId string) (preAuthCode string, err error)

func ExchangeToken

func ExchangeToken(clt *core.Client, appId string, componentAppId string, code string) (token *oauth2.Token, err error)

func FastRegisterAuthUrl

func FastRegisterAuthUrl(appId string, componentAppId string, redirectUri string) string

func GetSession

func GetSession(clt *core.Client, appId string, componentAppId string, code string) (info *oauth2.Session, err error)

func OpenBind

func OpenBind(clt *core.Client, appId string, openAppId string) (err error)

func OpenBindGet

func OpenBindGet(clt *core.Client) (openAppId string, err error)

func WxaAddCategory

func WxaAddCategory(clt *core.Client, first, second int, certicates []map[string]interface{}) (err error)

func WxaApplyPlugin

func WxaApplyPlugin(clt *core.Client, pluginAppid string, reason string) (err error)

func WxaBindTester

func WxaBindTester(clt *core.Client, wechatId string) (userstr string, err error)

func WxaCommit

func WxaCommit(clt *core.Client, templateId string, extJson string, userVersion string, userDesc string) (err error)

func WxaGetAllCategory

func WxaGetAllCategory(clt *core.Client) (cats []interface{}, err error)

func WxaGetPages

func WxaGetPages(clt *core.Client) (pages []string, err error)

func WxaGetTrailVersion

func WxaGetTrailVersion(clt *core.Client, path string) (contentType string, binary []byte, err error)

func WxaModifyWebviewDomain

func WxaModifyWebviewDomain(clt *core.Client, action DomainAction, list []string) (err error)

func WxaRelease

func WxaRelease(clt *core.Client) (err error)

func WxaSetAvatar

func WxaSetAvatar(clt *core.Client, mediaId string) (err error)

func WxaSetNickname

func WxaSetNickname(clt *core.Client, nickname string) (auditId int64, wording string, err error)

func WxaSetPrivacySetting

func WxaSetPrivacySetting(clt *core.Client, owner WxaOwnerSetting, items []WxaSettingItem) (err error)

func WxaSubmitAudit

func WxaSubmitAudit(clt *core.Client, versionDesc string) (auditid string, err error)

func WxaUndoCodeAudit

func WxaUndoCodeAudit(clt *core.Client) (err error)

func WxaWxPayAuth

func WxaWxPayAuth(clt *core.Client, action string, merchantNo string) (err error)

func WxaWxPayList

func WxaWxPayList(clt *core.Client) (list []interface{}, err error)

Types

type AccountInfo

type AccountInfo struct {
	Appid          string       `json:"appid"`
	AccountType    int          `json:"account_type"`    //帐号类型(1:订阅号,2:服务号,3:小程序)
	PrincipalType  int          `json:"principal_type"`  //主题类型
	PrincipalName  string       `json:"principal_name"`  //主体名称
	Credential     string       `json:"credential"`      //主体标识
	RealnameStatus interface{}  `json:"realname_status"` /*实名认证状态 1	实名验证成功 2	实名验证中 3	实名验证失败 //1、创建帐号时,实名验证状态会初始化为 2;对于注册方式为微信认证的帐号,资质认证成功时,realname_status 会更新为 1 2、当 realname_status 不为 1 时,帐号只允许调用以下 API(即无权限调用其他 API):微信认证相关接口和 帐号设置相关接口*/
	WxVerifyInfo   WxVerifyInfo `json:"wx_verify_info"`  //微信认证状态
	SignatureInfo  struct {
		Signature string `json:"signature"` //功能介绍
		Quota            //本月
	} `json:"signature_info"` //功能介绍信息
	HeadImageInfo struct {
		HeadImageUrl string `json:"head_image_url"` //头像
		Quota               //本年
	} `json:"head_image_info"` //头像信息
	NicknameInfo struct {
		Nickname string `json:"nickname"` //昵称
		Quota           //本年
	} `json:"nickname_info"` //昵称信息
	RegisteredCountry int `json:"registered_country"` //国家
}

func AccountBasicInfo

func AccountBasicInfo(clt *core.Client) (info *AccountInfo, err error)

type AuditStatus

type AuditStatus struct {
	Auditid    int    `json:"auditid"`
	Status     int    `json:"status"`
	Reason     string `json:"reason"`
	ScreenShot string `json:"ScreenShot"`
}

func WxaGetLatestAuditStatus

func WxaGetLatestAuditStatus(clt *core.Client) (status *AuditStatus, err error)

type AuthType

type AuthType int
const (
	AuthTypeOfficialAccount AuthType = 1
	AuthTypeMiniProgram     AuthType = 2
	AuthTypeBoth            AuthType = 3
)

type AuthorizationInfo

type AuthorizationInfo struct {
	AuthorizerAppid        string     `json:"authorizer_appid"`
	AuthorizerAccessToken  string     `json:"authorizer_access_token"`
	ExpiresIn              int64      `json:"expires_in"`
	AuthorizerRefreshToken string     `json:"authorizer_refresh_token"`
	FuncInfo               []FuncInfo `json:"func_info"`
}

func QueryAuthInfo

func QueryAuthInfo(clt *core.Client, appId string, authorizationCode string) (info *AuthorizationInfo, err error)

type BinaryResult

type BinaryResult struct {
	Error
	Binary      []byte `json:"binary"`
	ContentType string `json:"contentType"`
}

type Client

type Client struct {
	core.AccessTokenServer
	HttpClient *http.Client
}

func NewClient

func NewClient(srv core.AccessTokenServer, clt *http.Client) *Client

NewClient 创建一个新的 Client.

如果 clt == nil 则默认用 util.DefaultHttpClient

func (*Client) GetJSON

func (clt *Client) GetJSON(incompleteURL string, response interface{}) (err error)

GetJSON HTTP GET 微信资源, 然后将微信服务器返回的 JSON 用 encoding/json 解析到 response.

NOTE:
1. 一般不需要调用这个方法, 请直接调用高层次的封装函数;
2. 最终的 URL == incompleteURL + access_token;
3. response 格式有要求, 要么是 *Error, 要么是下面结构体的指针(注意 Error 必须是第一个 Field):
    struct {
        Error
        ...
    }

func (*Client) PostJSON

func (clt *Client) PostJSON(incompleteURL string, request interface{}, response interface{}) (err error)

PostJSON 用 encoding/json 把 request marshal 为 JSON, HTTP POST 到微信服务器, 然后将微信服务器返回的 JSON 用 encoding/json 解析到 response.

NOTE:
1. 一般不需要调用这个方法, 请直接调用高层次的封装函数;
2. 最终的 URL == incompleteURL + access_token;
3. response 格式有要求, 要么是 *Error, 要么是下面结构体的指针(注意 Error 必须是第一个 Field):
    struct {
        Error
        ...
    }

func (*Client) PostJSONBinary

func (clt *Client) PostJSONBinary(incompleteURL string, request interface{}, response *BinaryResult) (err error)

type Context

type Context struct {
	ResponseWriter http.ResponseWriter
	Request        *http.Request

	QueryParams  url.Values // 回调请求 URL 的查询参数集合
	EncryptType  string     // 回调请求 URL 的加密方式参数: encrypt_type
	MsgSignature string     // 回调请求 URL 的消息体签名参数: msg_signature
	Signature    string     // 回调请求 URL 的签名参数: signature
	Timestamp    int64      // 回调请求 URL 的时间戳参数: timestamp
	Nonce        string     // 回调请求 URL 的随机数参数: nonce

	MsgCiphertext []byte   // 消息的密文文本
	MsgPlaintext  []byte   // 消息的明文文本, xml格式
	InfoMsg       *InfoMsg // 消息

	Token  string // 当前消息所属公众号的 Token
	AESKey []byte // 当前消息加密所用的 aes-key, read-only!!!
	Random []byte // 当前消息加密所用的 random, 16-bytes
	AppId  string // 当前消息加密所用的 AppId
	// contains filtered or unexported fields
}

Context 是 Handler 处理消息(事件)的上下文环境. 非并发安全!

func (*Context) AESResponse

func (ctx *Context) AESResponse(msg interface{}, timestamp int64, nonce string, random []byte) (err error)

AESResponse 回复aes加密的消息给微信服务器.

msg:       经过 encoding/xml.Marshal 得到的结果符合微信消息格式的任何数据结构
timestamp: 时间戳, 如果为 0 则默认使用 Context.Timestamp
nonce:     随机数, 如果为 "" 则默认使用 Context.Nonce
random:    16字节的随机字符串, 如果为 nil 则默认使用 Context.Random

func (*Context) Abort

func (ctx *Context) Abort()

Abort 阻止系统调用当前 handler 后续的 handlers, 即当前的 handler 处理完毕就返回, 一般在 middleware 中调用.

func (*Context) Get

func (ctx *Context) Get(key string) (value interface{}, exists bool)

Get 返回 Context 中 key 对应的 value, 如果 key 存在的返回 (value, true), 否则返回 (nil, false).

func (*Context) IsAborted

func (ctx *Context) IsAborted() bool

IsAborted 返回 true 如果 Context.Abort() 被调用了, 否则返回 false.

func (*Context) MustGet

func (ctx *Context) MustGet(key string) interface{}

MustGet 返回 Context 中 key 对应的 value, 如果 key 不存在则会 panic.

func (*Context) Next

func (ctx *Context) Next()

Next 中断当前 handler 程序逻辑执行其后续的 handlers, 一般在 middleware 中调用.

func (*Context) NoneResponse

func (ctx *Context) NoneResponse() (err error)

NoneResponse 表示没有消息回复给微信服务器.

func (*Context) RawResponse

func (ctx *Context) RawResponse(msg interface{}) (err error)

RawResponse 回复明文消息给微信服务器.

msg: 经过 encoding/xml.Marshal 得到的结果符合微信消息格式的任何数据结构

func (*Context) Set

func (ctx *Context) Set(key string, value interface{})

Set 存储 key-value pair 到 Context 中.

func (*Context) SetHandlers

func (ctx *Context) SetHandlers(handlers HandlerChain)

SetHandlers 设置 handlers 给 Context.Next() 调用, 务必在 Context.Next() 调用之前设置, 否则会 panic.

NOTE: 此方法一般用不到, 除非你自己实现一个 Handler 给 Server 使用, 参考 ServeMux.

type DefaultAccessTokenServer

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

DefaultComponentAccessTokenServer 实现了 AccessTokenServer 开放平台接口.

NOTE:
1. 用于单进程环境.
2. 因为 DefaultComponentAccessTokenServer 同时也是一个简单的中控服务器, 而不是仅仅实现 AccessTokenServer 接口,
   所以整个系统只能存在一个 DefaultComponentAccessTokenServer 实例!

func NewDefaultAccessTokenServer

func NewDefaultAccessTokenServer(appId, componentAppId string,
	getComponentAccessToken func(componentAppId string) string,
	getRefreshToken func(appId string, componentAppId string) string, httpClient *http.Client) (srv *DefaultAccessTokenServer)

NewDefaultAccessTokenServer 创建一个新的 DefaultAccessTokenServer, 如果 httpClient == nil 则默认使用 util.DefaultHttpClient.

func (*DefaultAccessTokenServer) IID01332E16DF5011E5A9D5A4DB30FED8E1

func (srv *DefaultAccessTokenServer) IID01332E16DF5011E5A9D5A4DB30FED8E1()

func (*DefaultAccessTokenServer) RefreshToken

func (srv *DefaultAccessTokenServer) RefreshToken(currentToken string) (token string, err error)

func (*DefaultAccessTokenServer) Token

func (srv *DefaultAccessTokenServer) Token() (token string, err error)

type DefaultComponentAccessTokenServer

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

DefaultComponentAccessTokenServer 实现了 AccessTokenServer 开放平台接口.

NOTE:
1. 用于单进程环境.
2. 因为 DefaultComponentAccessTokenServer 同时也是一个简单的中控服务器, 而不是仅仅实现 AccessTokenServer 接口,
   所以整个系统只能存在一个 DefaultComponentAccessTokenServer 实例!

func NewDefaultComponentAccessTokenServer

func NewDefaultComponentAccessTokenServer(componentAppId, componentAppSecret string, getVerifyTicket func(appId string) string, httpClient *http.Client) (srv *DefaultComponentAccessTokenServer)

NewDefaultAccessTokenServer 创建一个新的 DefaultAccessTokenServer, 如果 httpClient == nil 则默认使用 util.DefaultHttpClient.

func (*DefaultComponentAccessTokenServer) IID01332E16DF5011E5A9D5A4DB30FED8E1

func (srv *DefaultComponentAccessTokenServer) IID01332E16DF5011E5A9D5A4DB30FED8E1()

func (*DefaultComponentAccessTokenServer) RefreshToken

func (srv *DefaultComponentAccessTokenServer) RefreshToken(currentToken string) (token string, err error)

func (*DefaultComponentAccessTokenServer) Token

func (srv *DefaultComponentAccessTokenServer) Token() (token string, err error)

type DomainAction

type DomainAction string
const (
	DomainActionAdd    DomainAction = "add"
	DomainActionDelete DomainAction = "delete"
	DomainActionSet    DomainAction = "set"
	DomainActionGet    DomainAction = "get"
)

type DomainList

type DomainList struct {
	RequestDomain   []string `json:"requestdomain"`
	WsRequestDomain []string `json:"wsrequestdomain"`
	UploadDomain    []string `json:"uploaddomain"`
	DownloadDomain  []string `json:"downloaddomain"`
}

func WxaModifyDomain

func WxaModifyDomain(clt *core.Client, action DomainAction, list DomainList) (rDomain *DomainList, err error)

type Error

type Error struct {
	ErrCode int64  `json:"errcode"`
	ErrMsg  string `json:"errmsg"`
}

func (*Error) Error

func (err *Error) Error() string

type ErrorHandler

type ErrorHandler interface {
	ServeError(http.ResponseWriter, *http.Request, error)
}
var DefaultErrorHandler ErrorHandler = ErrorHandlerFunc(defaultErrorHandlerFunc)

type ErrorHandlerFunc

type ErrorHandlerFunc func(http.ResponseWriter, *http.Request, error)

func (ErrorHandlerFunc) ServeError

func (fn ErrorHandlerFunc) ServeError(w http.ResponseWriter, r *http.Request, err error)

type FastRegisterInfo

type FastRegisterInfo struct {
	AppId             string `json:"appid"`
	AuthorizationCode string `json:"authorization_code"`
	IsWxVerifySucc    bool   `json:"is_wx_verify_succ"`
	IsLinkSucc        bool   `json:"is_link_succ"`
}

func FastRegister

func FastRegister(clt *core.Client, ticket string) (info *FastRegisterInfo, err error)

type FuncInfo

type FuncInfo struct {
	FuncScopeCategory FuncScopeCategory `json:"funcscope_category"`
}

type FuncScopeCategory

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

type FuncscopeCategoryId

type FuncscopeCategoryId int
const (
	FuncScopeCategoryOfficialAccountMessage        FuncscopeCategoryId = 1  // 消息管理权限	帮助公众号接收用户消息,进行人工客服回复或自动回复	否
	FuncScopeCategoryOfficialAccountUser           FuncscopeCategoryId = 2  // 用户管理权限	帮助公众号获取用户信息,进行用户管理	否
	FuncScopeCategoryOfficialAccountAccount        FuncscopeCategoryId = 3  // 帐号服务权限	帮助认证、设置公众号,进行帐号管理	否
	FuncScopeCategoryOfficialAccountWebService     FuncscopeCategoryId = 4  // 网页服务权限	帮助公众号实现第三方网页服务和活动	否
	FuncScopeCategoryOfficialAccountWeshop         FuncscopeCategoryId = 5  // 微信小店权限	帮助公众号使用微信小店	否
	FuncScopeCategoryOfficialAccountService        FuncscopeCategoryId = 6  // 微信多客服权限	帮助公众号使用微信多客服	否
	FuncScopeCategoryOfficialAccountNotice         FuncscopeCategoryId = 7  // 群发与通知权限	帮助公众号进行群发和模板消息业务通知	否
	FuncScopeCategoryOfficialAccountCard           FuncscopeCategoryId = 8  // 微信卡券权限	帮助公众号使用微信卡券	否	《微信公众平台卡券功能服务协议》
	FuncScopeCategoryOfficialAccountScan           FuncscopeCategoryId = 9  // 微信扫一扫权限	帮助公众号使用微信扫一扫	否	《微信公众平台扫一扫功能使用条款》
	FuncScopeCategoryOfficialAccountWifi           FuncscopeCategoryId = 10 // 微信连WIFI权限	帮助公众号使用微信连WIFI	否
	FuncScopeCategoryOfficialAccountMaterial       FuncscopeCategoryId = 11 // 素材管理权限	帮助公众号管理多媒体素材,用于客服等业务	否
	FuncScopeCategoryOfficialAccountNearby         FuncscopeCategoryId = 12 // 微信摇周边权限	帮助公众号使用微信摇周边	否
	FuncScopeCategoryOfficialAccountStore          FuncscopeCategoryId = 13 // 微信门店权限	帮助公众号使用微信门店	否
	FuncScopeCategoryOfficialAccountMenu           FuncscopeCategoryId = 15 // 自定义菜单权限	帮助公众号使用自定义菜单	否
	FuncScopeCategoryOfficialAccountCity           FuncscopeCategoryId = 22 // 城市服务接口权限	帮助城市服务内的服务向用户发送消息,沉淀办事记录,展示页卡及办事结果页	否
	FuncScopeCategoryOfficialAccountAd             FuncscopeCategoryId = 23 // 广告管理权限	帮助广告主进行微信广告的投放和管理	否
	FuncScopeCategoryOfficialAccountOpen           FuncscopeCategoryId = 24 // 开放平台帐号管理权限	帮助公众号绑定开放平台帐号,实现用户身份打通	是
	FuncScopeCategoryOfficialAccountTicket         FuncscopeCategoryId = 26 // 微信电子发票权限	帮助公众号使用微信电子发票	否
	FuncScopeCategoryOfficialAccountRegMp          FuncscopeCategoryId = 27 // 快速注册小程序权限	帮助公众号快速注册小程序	否
	FuncScopeCategoryOfficialAccountMgMp           FuncscopeCategoryId = 33 // 小程序管理权限	可新增关联小程序,并对公众号已关联的小程序进行管理	否
	FuncScopeCategoryOfficialAccountProduct        FuncscopeCategoryId = 34 // 微信商品库权限	帮助公众号商家导入、更新、查询商品信息,从而在返佣商品推广等场景使用	是
	FuncScopeCategoryOfficialAccountRun            FuncscopeCategoryId = 35 // 微信卡路里权限	为公众号提供用户卡路里同步、授权查询、兑换功能	否
	FuncScopeCategoryOfficialAccountGoods          FuncscopeCategoryId = 44 // 好物圈权限	帮助公众号将物品、订单、收藏等信息同步至好物圈,方便用户进行推荐	否
	FuncScopeCategoryOfficialAccountOneGoodOneCode FuncscopeCategoryId = 46 // 微信一物一码权限	帮助公众号使用微信一物一码功能	否
	FuncScopeCategoryOfficialAccountFinancial      FuncscopeCategoryId = 47 // 微信财政电子票据权限	帮助公众号完成授权、插卡及报销	否
	FuncScopeCategoryOfficialAccountSvcTalk        FuncscopeCategoryId = 54 // 服务号对话权限	帮助公众号配置对话能力,管理顾问、客户、标签和素材等	是	微信服务号对话能力功能服务条款》
	FuncScopeCategoryOfficialAccountSvcPlatform    FuncscopeCategoryId = 66 // 服务平台管理权限	帮助公众号管理服务平台上购买的资源	否
	FuncScopeCategoryOfficialAccountSubscribe      FuncscopeCategoryId = 89 // 订阅通知权限	帮助服务号使用订阅通知	否
)

公众号

const (
	FuncScopeCategoryMiniProgramWxacode           FuncscopeCategoryId = 17  // 获取小程序码	基于该权限可获取小程序码和小程序二维码	否
	FuncScopeCategoryMiniProgramDev               FuncscopeCategoryId = 18  // 小程序开发与数据分析	基于该权限可进行小程序开发以及代码管理和数据分析析。注意,小程序的开发权限集授权给服务商后,为了避免代码版本互相覆盖 ,小程序则无法再通过mp进行发版本。	是
	FuncScopeCategoryMiniProgramService           FuncscopeCategoryId = 19  // 小程序客服管理	基于该权限可实现在小程序中接收和发送客服消息以进行小程序客服消息管理	否
	FuncScopeCategoryMiniProgramOpen              FuncscopeCategoryId = 25  // 开放平台帐号管理	基于该权限可实现将小程序绑定/解除绑定开放平台帐号	是
	FuncScopeCategoryMiniProgramBasic             FuncscopeCategoryId = 30  // 小程序基本信息管理	基于该权限可设置小程序名称、头像、简介、类目等基本信息	否
	FuncScopeCategoryMiniProgramCertification     FuncscopeCategoryId = 31  // 小程序认证名称检测	基于该权限可进行检测小程序认证的名称是否符合规则	否
	FuncScopeCategoryMiniProgramRun               FuncscopeCategoryId = 36  // 微信卡路里管理	基于该权限可为小程序提供用户卡路里同步、授权查询、兑换功能	否
	FuncScopeCategoryMiniProgramNearby            FuncscopeCategoryId = 37  // 附近的小程序管理	基于该权限可为小程序创建附近地点,并设置小程序展示在“附近的小程序”入口中	否
	FuncScopeCategoryMiniProgramPlugins           FuncscopeCategoryId = 40  // 小程序插件管理	基于该权限可代小程序申请、添加和使用插件并进行管理	是
	FuncScopeCategoryMiniProgramGoods             FuncscopeCategoryId = 41  // 好物圈管理	基于该权限将小程序的物品、订单、收藏等信息同步至好物圈	是
	FuncScopeCategoryMiniProgramDelivery          FuncscopeCategoryId = 45  // 小程序快递配送	基于该权限可为小程序快速高效对接多家快递公司,对接后用户可通过微信服务通知接收实时快递配送状态,提升用户体验	是
	FuncScopeCategoryMiniProgramFinancial         FuncscopeCategoryId = 48  // 微信财政电子票据管理	基于该权限可为小程序完成微信财政电子票据授权、插卡及报销等功能	否
	FuncScopeCategoryMiniProgramDevCloud          FuncscopeCategoryId = 49  // 小程序云开发管理	基于该权限可为小程序管理云开发资源	是	《微信小程序·云开发功能服务条款》
	FuncScopeCategoryMiniProgramRealtimeDelivery  FuncscopeCategoryId = 51  // 小程序即时配送	基于该权限可为小程序快速高效对接多家配送公司的配送服务	是
	FuncScopeCategoryMiniProgramLiveStreaming     FuncscopeCategoryId = 52  // 小程序直播管理	基于该权限可为有直播需求的小程序实现直以及直播间管理等功能	否	《微信小程序直播功能服务条款》
	FuncScopeCategoryMiniProgramSearch            FuncscopeCategoryId = 57  // 小程序搜索	基于该权限可将小程序页面推送给搜索引擎,增加小程序页面在搜索的收录与曝光机会	否
	FuncScopeCategoryMiniProgramAd                FuncscopeCategoryId = 65  // 小程序广告管理	基于该权限可为小程序广告主进行微信广告的投放和管理	否
	FuncScopeCategoryMiniProgramSvcPlatform       FuncscopeCategoryId = 67  // 微信服务平台管理	基于该权限可代小程序调用在微信服务平台购买的API资源	否
	FuncScopeCategoryMiniProgramStandTradeProduct FuncscopeCategoryId = 70  // 标准版交易组件商品管理	基于该权限可对小商店或者标准版交易组件的商品及库存信息进行管理	否
	FuncScopeCategoryMiniProgramStandTradeOrder   FuncscopeCategoryId = 71  // 标准版交易组件订单物流与售后管理	基于该权限可对小商店或者标准版交易组件的订单、物流信息及售后相关内容进行管理	否
	FuncScopeCategoryMiniProgramStandTradeImport  FuncscopeCategoryId = 73  // 标准版交易组件接入	基于该权限可快速开通小程序并同时开通标准版交易组件,或者快速调用接口开通小商店	是
	FuncScopeCategoryMiniProgramViolation         FuncscopeCategoryId = 76  // 小程序违规与交易投诉管理	基于该权限可接收小程序违规信息和发起申诉请求以及可用于接收、查询、处理小程序用户交易类投诉	是
	FuncScopeCategoryMiniProgramTry               FuncscopeCategoryId = 81  // 试用小程序快速认证	基于该权限可为试用小程序快速完成认证	是
	FuncScopeCategoryMiniProgramStandTradeCoupon  FuncscopeCategoryId = 84  // 标准版交易组件优惠券管理	基于该权限可对小商店或者标准版交易组件的优惠券进行管理,可完成优惠券的制作、发放、信息的搜集等功能	否
	FuncScopeCategoryMiniProgramCustomTrade       FuncscopeCategoryId = 85  // 自定义版交易组件管理	基于该权限可为小程序实现自定义版交易组件的接入、商品、订单、物流、售后管理等功能	是
	FuncScopeCategoryMiniProgramShopFurnish       FuncscopeCategoryId = 86  // 小商店装修	基于该权限实现小商店的装修功能	否
	FuncScopeCategoryMiniProgramWxaLink           FuncscopeCategoryId = 88  // 获取小程序链接	基于该权限可获取小程序URL Scheme、URL Link以及Short Link,从而实现从短信、邮件、微信外网页等场景打开小程序以及在微信内拉起小程序	是
	FuncScopeCategoryMiniProgramWxaUnion          FuncscopeCategoryId = 93  // 小程序联盟管理	基于该权限可为需要推广商品的推客查询商品、并生成相应的推广素材,推广完成后可为推客查询推广订单明细	否
	FuncScopeCategoryMiniProgramDevCloudSms       FuncscopeCategoryId = 99  // 云开发短信服务	基于该权限可为小程序提供基于云开发的短信服务,可实现从短信打开云开发静态页面或小程序	否
	FuncScopeCategoryMiniProgramDevCloudPay       FuncscopeCategoryId = 102 // 云开发微信支付	基于该权限可为小程序使用基于云开发的绑定微信支付商户号、查询绑定的商户号等功能	否
)

小程序

type Handler

type Handler interface {
	ServeMsg(*Context)
}

type HandlerChain

type HandlerChain []Handler

type HandlerFunc

type HandlerFunc func(*Context)

func (HandlerFunc) ServeMsg

func (fn HandlerFunc) ServeMsg(ctx *Context)

type InfoMsg

type InfoMsg struct {
	InfoType                     InfoType `xml:"InfoType" json:"InfoType"`
	AppId                        string   `xml:"AppId" json:"AppId"`
	CreateTime                   int64    `xml:"CreateTime" json:"CreateTime"`
	ComponentVerifyTicket        string   `xml:"ComponentVerifyTicket" json:"ComponentVerifyTicket"`
	AuthorizerAppid              string   `xml:"AuthorizerAppid" json:"AuthorizerAppid"`
	AuthorizationCode            string   `xml:"AuthorizationCode" json:"AuthorizationCode"`
	AuthorizationCodeExpiredTime int64    `xml:"AuthorizationCodeExpiredTime" json:"AuthorizationCodeExpiredTime"`
	PreAuthCode                  string   `xml:"PreAuthCode" json:"PreAuthCode"`
}

type InfoType

type InfoType string
const (
	InfoTypeComponentVerifyTicket InfoType = "component_verify_ticket" //开放平台票据验证
	InfoTypeUnauthorized          InfoType = "unauthorized"            //取消授权
	InfoTypeUpdateauthorized      InfoType = "updateauthorized"        //更新授权
	InfoTypeAuthorized            InfoType = "authorized"              //授权成功
)

type Quota

type Quota struct {
	ModifyUsedCount int `json:"modify_used_count"` //已使用修改次数
	ModifyQuota     int `json:"modify_quota"`      //修改次数总额度
}

type ServeMux

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

ServeMux 是一个消息(事件)路由器, 同时也是一个 Handler 的实现.

NOTE: ServeMux 非并发安全, 如果需要并发安全的 Handler, 可以参考 ServeMux 实现一个.

func NewServeMux

func NewServeMux() *ServeMux

func (*ServeMux) DefaultInfoHandle

func (mux *ServeMux) DefaultInfoHandle(handlers ...Handler)

DefaultEventHandle 设置 handlers 以处理没有匹配到具体类型的 HandlerChain 的事件.

func (*ServeMux) DefaultInfoHandleFunc

func (mux *ServeMux) DefaultInfoHandleFunc(handlers ...func(*Context))

DefaultEventHandleFunc 设置 handlers 以处理没有匹配到具体类型的 HandlerChain 的事件.

func (*ServeMux) InfoHandle

func (mux *ServeMux) InfoHandle(eventType InfoType, handlers ...Handler)

EventHandle 设置 handlers 以处理特定类型的事件.

func (*ServeMux) InfoHandleFunc

func (mux *ServeMux) InfoHandleFunc(eventType InfoType, handlers ...func(*Context))

EventHandleFunc 设置 handlers 以处理特定类型的事件.

func (*ServeMux) ServeMsg

func (mux *ServeMux) ServeMsg(ctx *Context)

ServeMsg 实现 Handler 接口.

func (*ServeMux) Use

func (mux *ServeMux) Use(middlewares ...Handler)

Use 注册(新增) middlewares 使其在所有消息(事件)的 Handler 之前处理该处理消息(事件).

func (*ServeMux) UseForInfo

func (mux *ServeMux) UseForInfo(middlewares ...Handler)

UseForEvent 注册(新增) middlewares 使其在所有事件的 Handler 之前处理该处理事件.

func (*ServeMux) UseFunc

func (mux *ServeMux) UseFunc(middlewares ...func(*Context))

UseFunc 注册(新增) middlewares 使其在所有消息(事件)的 Handler 之前处理该处理消息(事件).

func (*ServeMux) UseFuncForInfo

func (mux *ServeMux) UseFuncForInfo(middlewares ...func(*Context))

UseFuncForEvent 注册(新增) middlewares 使其在所有事件的 Handler 之前处理该处理事件.

type Server

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

Server 用于处理微信服务器的回调请求, 并发安全!

通常情况下一个 Server 实例用于处理一个公众号的消息(事件), 此时建议指定 oriId(原始ID) 和 appId(明文模式下无需指定) 用于约束消息(事件);
特殊情况下也可以一个 Server 实例用于处理多个公众号的消息(事件), 此时要求这些公众号的 token 是一样的, 并且 oriId 和 appId 必须设置为 "".

func NewServer

func NewServer(appId, token, base64AESKey string, handler Handler, errorHandler ErrorHandler) (srv *Server)

NewServer 创建一个新的 Server.

appId:        可选; 公众号的AppId, 如果设置了值则安全模式时该Server只能处理 AppId 为该值的公众号的消息(事件);
token:        必须; 公众号用于验证签名的token;
base64AESKey: 可选; aes加密解密key, 43字节长(base64编码, 去掉了尾部的'='), 安全模式必须设置;
handler:      必须; 处理微信服务器推送过来的消息(事件)的Handler;
errorHandler: 可选; 用于处理Server在处理消息(事件)过程中产生的错误, 如果没有设置则默认使用 DefaultErrorHandler.

func (*Server) AppId

func (srv *Server) AppId() string
func (srv *Server) OriId() string {
	return srv.oriId
}

func (*Server) ServeHTTP

func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request, query url.Values)

ServeHTTP 处理微信服务器的回调请求, query 参数可以为 nil.

func (*Server) SetAESKey

func (srv *Server) SetAESKey(base64AESKey string) (err error)

SetAESKey 设置aes加密解密key.

base64AESKey: aes加密解密key, 43字节长(base64编码, 去掉了尾部的'=').

func (*Server) SetToken

func (srv *Server) SetToken(token string) (err error)

SetToken 设置签名token.

type SpuItem

type SpuItem struct {
	ProductId    int64       `json:"product_id"`
	OutProductId string      `json:"out_product_id"`
	Title        string      `json:"title"`
	SubTitle     string      `json:"sub_title"`
	HeadImg      []string    `json:"head_img"`
	DescInfo     interface{} `json:"desc_info"`
	Status       int         `json:"status"`
	EditStatus   int         `json:"edit_status"`
	MinPrice     int         `json:"min_price"`
	Path         string      `json:"path"`
}

type SpuResult

type SpuResult struct {
	TotalNum int       `json:"total_num"`
	Spus     []SpuItem `json:"spus"`
}

func TradeGetSpuList

func TradeGetSpuList(clt *core.Client, status int, page int, pageSize int, needEditSpu int, source int) (spu SpuResult, err error)

type WxVerifyInfo

type WxVerifyInfo struct {
	QualificationVerify   bool  `json:"qualification_verify"`     //是否资质认证,若是,拥有微信认证相关的权限。
	NamingVerify          bool  `json:"naming_verify"`            //是否名称认证
	AnnualReview          bool  `json:"annual_review"`            //是否需要年审(qualification_verify == true 时才有该字段)
	AnnualReviewBeginTime int64 `json:"annual_review_begin_time"` //年审开始时间,时间戳(qualification_verify == true 时才有该字段)
	AnnualReviewEndTime   int64 `json:"annual_review_end_time"`   //年审截止时间,时间戳(qualification_verify == true 时才有该字段)
}

type WxaOwnerSetting

type WxaOwnerSetting struct {
	ContactEmail         string `json:"contact_email"`
	ContactPhone         string `json:"contact_phone"`
	ContactQq            string `json:"contact_qq"`
	ContactWeixin        string `json:"contact_weixin"`
	ExtFileMediaId       string `json:"ext_file_media_id"`
	NoticeMethod         string `json:"notice_method"`
	StoreExpireTimestamp string `json:"store_expire_timestamp"`
}

type WxaPrivacySetting

type WxaPrivacySetting struct {
	CodeExist    int              `json:"code_exist"`
	PrivacyList  []string         `json:"privacy_list"`
	SettingList  []WxaSettingItem `json:"setting_list"`
	UpdateTime   int64            `json:"update_time"`
	OwnerSetting WxaOwnerSetting  `json:"owner_setting"`
	PrivacyDesc  struct {
		PrivacyDescList []WxaSettingItem `json:"privacy_desc_list"`
	} `json:"privacy_desc"`
}

func WxaGetPrivacySetting

func WxaGetPrivacySetting(clt *core.Client) (setting WxaPrivacySetting, err error)

type WxaSettingItem

type WxaSettingItem struct {
	PrivacyKey   string `json:"privacy_key"`
	PrivacyText  string `json:"privacy_text"`
	PrivacyLabel string `json:"privacy_label"`
}

Jump to

Keyboard shortcuts

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