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.
go-library/service/wechatopen/wxa.bind_tester.go

57 lines
1.9 KiB

2 years ago
package wechatopen
import (
2 years ago
"context"
1 year ago
"github.com/dtapps/go-library/utils/gojson"
2 years ago
"github.com/dtapps/go-library/utils/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 // 内容
Http gorequest.Response // 请求
2 years ago
}
func newWxaBindTesterResult(result WxaBindTesterResponse, body []byte, http gorequest.Response) *WxaBindTesterResult {
return &WxaBindTesterResult{Result: result, Body: body, Http: http}
2 years ago
}
// WxaBindTester 绑定微信用户为体验者
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_AdminManagement/Admin.html
12 months ago
func (c *Client) WxaBindTester(ctx context.Context, authorizerAccessToken, wechatid string, notMustParams ...gorequest.Params) (*WxaBindTesterResult, error) {
2 years ago
// 参数
params := gorequest.NewParamsWith(notMustParams...)
2 years ago
params["wechatid"] = wechatid
// 请求
12 months ago
request, err := c.request(ctx, apiUrl+"/wxa/bind_tester?access_token="+authorizerAccessToken, params, http.MethodPost)
if err != nil {
return newWxaBindTesterResult(WxaBindTesterResponse{}, request.ResponseBody, request), err
}
2 years ago
// 定义
var response WxaBindTesterResponse
1 year ago
err = gojson.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 "系统繁忙"
}