schema
This commit is contained in:
parent
edc2466eee
commit
dba4fdac2f
|
@ -108,3 +108,45 @@ func (o *MpSdk) GetUnlimitedQRCode(params map[string]interface{}) ([]byte, error
|
|||
|
||||
return body, nil
|
||||
}
|
||||
|
||||
func (o *MpSdk) GetScheme(params map[string]interface{}) (string, error) {
|
||||
if _, ok := params["path"]; !ok {
|
||||
return "", errors.New("path参数缺失")
|
||||
}
|
||||
|
||||
if _, ok := params["env_version"]; !ok {
|
||||
params["env_version"] = "release"
|
||||
}
|
||||
|
||||
jump_wxa := make(map[string]interface{})
|
||||
|
||||
jump_wxa["env_version"] = params["env_version"]
|
||||
jump_wxa["path"] = params["path"]
|
||||
jump_wxa["query"] = params["query"]
|
||||
params["jump_wxa"] = jump_wxa
|
||||
|
||||
params["expire_interval"] = 30
|
||||
params["expire_type"] = 1
|
||||
params["is_expire"] = true
|
||||
|
||||
marshal, _ := json.Marshal(params)
|
||||
accessToken, err := o.getAccessToken()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
url := fmt.Sprintf("%s?access_token=%s", getWxACodeUnLimitUrl, accessToken)
|
||||
res, _ := http.Post(url, "application/json", bytes.NewBuffer(marshal))
|
||||
body, err := io.ReadAll(res.Body)
|
||||
defer res.Body.Close()
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
g := gjson.ParseBytes(body)
|
||||
errcode := g.Get("errcode").Int()
|
||||
if errcode != 0 {
|
||||
return "", fmt.Errorf("%d:%s", errcode, g.Get("errmsg"))
|
||||
}
|
||||
return g.Get("openlink").String(), nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue