1
0
mirror of https://github.com/silenceper/wechat.git synced 2026-02-04 12:52:27 +08:00

[feature] Format the code and improve Mini Program authorization to o… (#473)

* [feature] Format the code and improve Mini Program authorization to obtain openid(miniprogram/auth/auth.go Code2Session)

* [feature] CheckEncryptedData (https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/user-info/auth.checkEncryptedData.html)

* upgrade json error

* upgrade json error

Co-authored-by: houseme <houseme@outlook.com>
This commit is contained in:
houseme
2021-09-08 11:03:23 +08:00
committed by GitHub
parent 47adf42208
commit 96c1f98944
90 changed files with 787 additions and 760 deletions

View File

@@ -8,34 +8,34 @@ import (
)
var (
//获取微信服务器IP地址
//文档https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_the_WeChat_server_IP_address.html
// 获取微信服务器IP地址
// 文档https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_the_WeChat_server_IP_address.html
getCallbackIPURL = "https://api.weixin.qq.com/cgi-bin/getcallbackip"
getAPIDomainIPURL = "https://api.weixin.qq.com/cgi-bin/get_api_domain_ip"
//清理接口调用次数
// 清理接口调用次数
clearQuotaURL = "https://api.weixin.qq.com/cgi-bin/clear_quota"
)
//Basic struct
// Basic struct
type Basic struct {
*context.Context
}
//NewBasic 实例
// NewBasic 实例
func NewBasic(context *context.Context) *Basic {
basic := new(Basic)
basic.Context = context
return basic
}
//IPListRes 获取微信服务器IP地址 返回结果
// IPListRes 获取微信服务器IP地址 返回结果
type IPListRes struct {
util.CommonError
IPList []string `json:"ip_list"`
}
//GetCallbackIP 获取微信callback IP地址
// GetCallbackIP 获取微信callback IP地址
func (basic *Basic) GetCallbackIP() ([]string, error) {
ak, err := basic.GetAccessToken()
if err != nil {
@@ -51,7 +51,7 @@ func (basic *Basic) GetCallbackIP() ([]string, error) {
return ipListRes.IPList, err
}
//GetAPIDomainIP 获取微信API接口 IP地址
// GetAPIDomainIP 获取微信API接口 IP地址
func (basic *Basic) GetAPIDomainIP() ([]string, error) {
ak, err := basic.GetAccessToken()
if err != nil {
@@ -67,7 +67,7 @@ func (basic *Basic) GetAPIDomainIP() ([]string, error) {
return ipListRes.IPList, err
}
//ClearQuota 清理接口调用次数
// ClearQuota 清理接口调用次数
func (basic *Basic) ClearQuota() error {
ak, err := basic.GetAccessToken()
if err != nil {