You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.7 KiB
55 lines
1.7 KiB
2 years ago
|
package wechatopen
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
2 years ago
|
"go.dtapp.net/library/gorequest"
|
||
2 years ago
|
"net/http"
|
||
|
)
|
||
|
|
||
|
type WxaBindTesterResponse struct {
|
||
|
Errcode int `json:"errcode"` // 错误码
|
||
|
Errmsg string `json:"errmsg"` // 错误信息
|
||
|
Userstr string `json:"userstr"` // 人员对应的唯一字符串
|
||
|
}
|
||
|
|
||
|
type WxaBindTesterResult struct {
|
||
|
Result WxaBindTesterResponse // 结果
|
||
|
Body []byte // 内容
|
||
2 years ago
|
Http gorequest.Response // 请求
|
||
2 years ago
|
Err error // 错误
|
||
|
}
|
||
|
|
||
2 years ago
|
func NewWxaBindTesterResult(result WxaBindTesterResponse, body []byte, http gorequest.Response, err error) *WxaBindTesterResult {
|
||
|
return &WxaBindTesterResult{Result: result, Body: body, Http: http, Err: err}
|
||
2 years ago
|
}
|
||
|
|
||
|
// WxaBindTester 绑定微信用户为体验者
|
||
|
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_AdminManagement/Admin.html
|
||
|
func (app *App) WxaBindTester(wechatid string) *WxaBindTesterResult {
|
||
|
// 参数
|
||
|
params := NewParams()
|
||
|
params["wechatid"] = wechatid
|
||
|
// 请求
|
||
2 years ago
|
request, err := app.request(fmt.Sprintf("https://api.weixin.qq.com/wxa/bind_tester?access_token=%s", app.GetAuthorizerAccessToken()), params, http.MethodPost)
|
||
2 years ago
|
// 定义
|
||
|
var response WxaBindTesterResponse
|
||
2 years ago
|
err = json.Unmarshal(request.ResponseBody, &response)
|
||
|
return NewWxaBindTesterResult(response, request.ResponseBody, request, err)
|
||
2 years ago
|
}
|
||
|
|
||
|
// ErrcodeInfo 错误描述
|
||
|
func (resp *WxaBindTesterResult) ErrcodeInfo() string {
|
||
|
switch resp.Result.Errcode {
|
||
|
case 85001:
|
||
|
return "微信号不存在或微信号设置为不可搜索"
|
||
|
case 85002:
|
||
|
return "小程序绑定的体验者数量达到上限"
|
||
|
case 85003:
|
||
|
return "微信号绑定的小程序体验者达到上限"
|
||
|
case 85004:
|
||
|
return "微信号已经绑定"
|
||
|
}
|
||
|
return "系统繁忙"
|
||
|
}
|