mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-06 13:42:26 +08:00
improve comment ,参考:https://github.com/huacnlee/autocorrect
This commit is contained in:
@@ -19,7 +19,7 @@ cfg := &openplatform.Config{
|
||||
|
||||
|
||||
openPlatform := wc.GetOpenPlatform(cfg)
|
||||
// 传入request和responseWriter
|
||||
// 传入 request 和 responseWriter
|
||||
server := openPlatform.GetServer(req, rw)
|
||||
//设置接收消息的处理方法
|
||||
server.SetMessageHandler(func(msg *message.MixMessage) *message.Reply {
|
||||
@@ -57,7 +57,7 @@ server.Send()
|
||||
|
||||
```go
|
||||
|
||||
//授权的第三方公众号的appID
|
||||
//授权的第三方公众号的 appID
|
||||
appID := "xxx"
|
||||
openPlatform := wc.GetOpenPlatform(cfg)
|
||||
openPlatform.GetOfficialAccount(appID)
|
||||
|
||||
@@ -53,7 +53,7 @@ func (basic *Basic) GetAccountBasicInfo() (*AccountBasicInfo, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// modify_domain设置服务器域名
|
||||
// modify_domain 设置服务器域名
|
||||
// TODO
|
||||
// func (encryptor *Basic) modifyDomain() {
|
||||
// }
|
||||
@@ -87,7 +87,7 @@ func (basic *Basic) CheckNickName(nickname string) (*CheckNickNameResp, error) {
|
||||
// SetNickNameResp 设置小程序名称结果
|
||||
type SetNickNameResp struct {
|
||||
util.CommonError
|
||||
AuditID int64 `json:"audit_id"` // 审核单Id,通过用于查询改名审核状态
|
||||
AuditID int64 `json:"audit_id"` // 审核单 Id,通过用于查询改名审核状态
|
||||
Wording string `json:"wording"` // 材料说明
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ func (basic *Basic) SetHeadImage(imgMediaID string) error {
|
||||
}
|
||||
|
||||
// SetHeadImageFull 修改小程序头像
|
||||
// 新增临时素材: https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/New_temporary_materials.html
|
||||
// 新增临时素材:https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/New_temporary_materials.html
|
||||
// ref: https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/miniprogram-management/basic-info-management/setHeadImage.html
|
||||
func (basic *Basic) SetHeadImageFull(param *SetHeadImageParam) error {
|
||||
ak, err := basic.GetAuthrAccessToken(basic.AppID)
|
||||
|
||||
@@ -25,7 +25,7 @@ func NewComponent(opContext *openContext.Context) *Component {
|
||||
type RegisterMiniProgramParam struct {
|
||||
Name string `json:"name"` // 企业名
|
||||
Code string `json:"code"` // 企业代码
|
||||
CodeType string `json:"code_type"` // 企业代码类型 1:统一社会信用代码(18 位) 2:组织机构代码(9 位 xxxxxxxx-x) 3:营业执照注册号(15 位)
|
||||
CodeType string `json:"code_type"` // 企业代码类型 1:统一社会信用代码(18 位)2:组织机构代码(9 位 xxxxxxxx-x)3:营业执照注册号 (15 位)
|
||||
LegalPersonaWechat string `json:"legal_persona_wechat"` // 法人微信号
|
||||
LegalPersonaName string `json:"legal_persona_name"` // 法人姓名(绑定银行卡)
|
||||
ComponentPhone string `json:"component_phone"` // 第三方联系电话(方便法人与第三方联系)
|
||||
@@ -54,7 +54,7 @@ type GetRegistrationStatusParam struct {
|
||||
|
||||
}
|
||||
|
||||
// GetRegistrationStatus 查询创建任务状态.
|
||||
// GetRegistrationStatus 查询创建任务状态。
|
||||
func (component *Component) GetRegistrationStatus(param *GetRegistrationStatusParam) error {
|
||||
componentAK, err := component.GetComponentAccessToken()
|
||||
if err != nil {
|
||||
|
||||
@@ -21,7 +21,7 @@ type MiniProgram struct {
|
||||
authorizerRefreshToken string
|
||||
}
|
||||
|
||||
// GetAccessToken 获取ak
|
||||
// GetAccessToken 获取 ak
|
||||
func (miniProgram *MiniProgram) GetAccessToken() (string, error) {
|
||||
ak, akErr := miniProgram.openContext.GetAuthrAccessToken(miniProgram.AppID)
|
||||
if akErr == nil {
|
||||
@@ -37,7 +37,7 @@ func (miniProgram *MiniProgram) GetAccessToken() (string, error) {
|
||||
return akRes.AccessToken, nil
|
||||
}
|
||||
|
||||
// SetAuthorizerRefreshToken 设置代执操作业务授权账号authorizer_refresh_token
|
||||
// SetAuthorizerRefreshToken 设置代执操作业务授权账号 authorizer_refresh_token
|
||||
func (miniProgram *MiniProgram) SetAuthorizerRefreshToken(authorizerRefreshToken string) *MiniProgram {
|
||||
miniProgram.authorizerRefreshToken = authorizerRefreshToken
|
||||
return miniProgram
|
||||
@@ -49,7 +49,7 @@ func NewMiniProgram(opCtx *openContext.Context, appID string) *MiniProgram {
|
||||
AppID: opCtx.AppID,
|
||||
Cache: opCtx.Cache,
|
||||
})
|
||||
// 设置获取access_token的函数
|
||||
// 设置获取 access_token 的函数
|
||||
miniProgram.SetAccessTokenHandle(NewDefaultAuthrAccessToken(opCtx, appID))
|
||||
return &MiniProgram{AppID: appID, MiniProgram: miniProgram, openContext: opCtx}
|
||||
}
|
||||
@@ -65,20 +65,20 @@ func (miniProgram *MiniProgram) GetBasic() *basic.Basic {
|
||||
return basic.NewBasic(miniProgram.openContext, miniProgram.AppID)
|
||||
}
|
||||
|
||||
// GetURLLink 小程序URL Link接口 调用前需确认已调用 SetAuthorizerRefreshToken 避免由于缓存中 authorizer_access_token 过期执行中断
|
||||
// GetURLLink 小程序 URL Link 接口 调用前需确认已调用 SetAuthorizerRefreshToken 避免由于缓存中 authorizer_access_token 过期执行中断
|
||||
func (miniProgram *MiniProgram) GetURLLink() *urllink.URLLink {
|
||||
return urllink.NewURLLink(&miniContext.Context{
|
||||
AccessTokenHandle: miniProgram,
|
||||
})
|
||||
}
|
||||
|
||||
// DefaultAuthrAccessToken 默认获取授权ak的方法
|
||||
// DefaultAuthrAccessToken 默认获取授权 ak 的方法
|
||||
type DefaultAuthrAccessToken struct {
|
||||
opCtx *openContext.Context
|
||||
appID string
|
||||
}
|
||||
|
||||
// NewDefaultAuthrAccessToken 设置access_token
|
||||
// NewDefaultAuthrAccessToken 设置 access_token
|
||||
func NewDefaultAuthrAccessToken(opCtx *openContext.Context, appID string) credential.AccessTokenHandle {
|
||||
return &DefaultAuthrAccessToken{
|
||||
opCtx: opCtx,
|
||||
@@ -86,7 +86,7 @@ func NewDefaultAuthrAccessToken(opCtx *openContext.Context, appID string) creden
|
||||
}
|
||||
}
|
||||
|
||||
// GetAccessToken 获取ak
|
||||
// GetAccessToken 获取 ak
|
||||
func (ak *DefaultAuthrAccessToken) GetAccessToken() (string, error) {
|
||||
return ak.opCtx.GetAuthrAccessToken(ak.appID)
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ func NewJs(context *context.Context, appID string) *Js {
|
||||
return js
|
||||
}
|
||||
|
||||
// SetJsTicketHandle 自定义js ticket取值方式
|
||||
// SetJsTicketHandle 自定义 js ticket 取值方式
|
||||
func (js *Js) SetJsTicketHandle(ticketHandle credential.JsTicketHandle) {
|
||||
js.JsTicketHandle = ticketHandle
|
||||
}
|
||||
|
||||
// GetConfig 第三方平台 - 获取jssdk需要的配置参数
|
||||
// GetConfig 第三方平台 - 获取 jssdk 需要的配置参数
|
||||
// uri 为当前网页地址
|
||||
func (js *Js) GetConfig(uri, appid string) (config *officialJs.Config, err error) {
|
||||
config = new(officialJs.Config)
|
||||
|
||||
@@ -16,19 +16,19 @@ const (
|
||||
platformAccessTokenURL = "https://api.weixin.qq.com/sns/oauth2/component/access_token?appid=%s&code=%s&grant_type=authorization_code&component_appid=%s&component_access_token=%s"
|
||||
)
|
||||
|
||||
// Oauth 平台代发起oauth2网页授权
|
||||
// Oauth 平台代发起 oauth2 网页授权
|
||||
type Oauth struct {
|
||||
*context.Context
|
||||
}
|
||||
|
||||
// NewOauth 实例化平台代发起oauth2网页授权
|
||||
// NewOauth 实例化平台代发起 oauth2 网页授权
|
||||
func NewOauth(context *context.Context) *Oauth {
|
||||
auth := new(Oauth)
|
||||
auth.Context = context
|
||||
return auth
|
||||
}
|
||||
|
||||
// GetRedirectURL 第三方平台 - 获取跳转的url地址
|
||||
// GetRedirectURL 第三方平台 - 获取跳转的 url 地址
|
||||
func (oauth *Oauth) GetRedirectURL(redirectURI, scope, state, appID string) (string, error) {
|
||||
// url encode
|
||||
urlStr := url.QueryEscape(redirectURI)
|
||||
@@ -45,7 +45,7 @@ func (oauth *Oauth) Redirect(writer http.ResponseWriter, req *http.Request, redi
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetUserAccessToken 第三方平台 - 通过网页授权的code 换取access_token(区别于context中的access_token)
|
||||
// GetUserAccessToken 第三方平台 - 通过网页授权的 code 换取 access_token(区别于 context 中的 access_token)
|
||||
func (oauth *Oauth) GetUserAccessToken(code, appID, componentAccessToken string) (result officialOauth.ResAccessToken, err error) {
|
||||
urlStr := fmt.Sprintf(platformAccessTokenURL, appID, code, oauth.AppID, componentAccessToken)
|
||||
var response []byte
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/silenceper/wechat/v2/openplatform/officialaccount"
|
||||
)
|
||||
|
||||
// OpenPlatform 微信开放平台相关api
|
||||
// OpenPlatform 微信开放平台相关 api
|
||||
type OpenPlatform struct {
|
||||
*context.Context
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user