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.
wechatopen/cgi-bin.wxopen.qrcodejumpad...

78 lines
2.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package wechatopen
import (
"context"
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
"net/http"
)
type CgiBinWxOpenQrCodeJumpAddResponse struct {
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
}
type CgiBinWxOpenQrCodeJumpAddResult struct {
Result CgiBinWxOpenQrCodeJumpAddResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
}
func newCgiBinWxOpenQrCodeJumpAddResult(result CgiBinWxOpenQrCodeJumpAddResponse, body []byte, http gorequest.Response) *CgiBinWxOpenQrCodeJumpAddResult {
return &CgiBinWxOpenQrCodeJumpAddResult{Result: result, Body: body, Http: http}
}
// CgiBinWxOpenQrCodeJumpAdd 增加或修改二维码规则
// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/qrcode/qrcodejumpadd.html
func (c *Client) CgiBinWxOpenQrCodeJumpAdd(ctx context.Context, notMustParams ...gorequest.Params) (*CgiBinWxOpenQrCodeJumpAddResult, error) {
// 检查
err := c.checkComponentIsConfig()
if err != nil {
return nil, err
}
err = c.checkAuthorizerIsConfig()
if err != nil {
return nil, err
}
// 参数
params := gorequest.NewParamsWith(notMustParams...)
// 请求
request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/cgi-bin/wxopen/qrcodejumpadd?access_token=%s", c.GetAuthorizerAccessToken(ctx)), params, http.MethodPost)
if err != nil {
return nil, err
}
// 定义
var response CgiBinWxOpenQrCodeJumpAddResponse
err = json.Unmarshal(request.ResponseBody, &response)
if err != nil {
return nil, err
}
return newCgiBinWxOpenQrCodeJumpAddResult(response, request.ResponseBody, request), nil
}
// ErrcodeInfo 错误描述
func (resp *CgiBinWxOpenQrCodeJumpAddResult) ErrcodeInfo() string {
switch resp.Result.Errcode {
case 44990:
return "接口请求太快超过5次/秒)"
case 85066:
return "链接错误"
case 85068:
return "测试链接不是子链接"
case 85069:
return "校验文件失败"
case 85070:
return "URL命中黑名单无法添加"
case 85071:
return "已添加该链接,请勿重复添加"
case 85072:
return "该链接已被占用"
case 85073:
return "二维码规则已满"
case 85075:
return "个人类型小程序无法设置二维码规则"
}
return "系统繁忙"
}