This commit is contained in:
邹宗楠
2022-08-12 09:41:55 +08:00
parent 3d7f18b857
commit a6ad2b629a

View File

@@ -2,7 +2,6 @@ package weixinapi
import (
"bytes"
"fmt"
"git.rosy.net.cn/baseapi/utils"
)
@@ -139,20 +138,19 @@ func (a *API) SNSCode2Session(jsCode string) (sessionInfo *SessionInfo, err erro
}
func (a *API) SNSGetUserPhone(jsCode string) (string, error) {
url := "wxa/business/getuserphonenumber?access_token=%s"
url := "wxa/business/getuserphonenumber"
if a.token == "" {
a.CBRetrieveToken()
url = fmt.Sprintf(url, a.CBGetToken())
} else {
url = fmt.Sprintf(url, a.token)
}
result, err := a.AccessAPI(url, map[string]interface{}{
"js_code": jsCode,
}, "1")
bodyJson := map[string]interface{}{
"code": jsCode,
}
result, err := a.AccessAPI(url, nil, string(utils.MustMarshal(bodyJson)))
if err != nil {
return "", err
}
if result["errcode"].(int) != 0 {
if result["errcode"].(string) != "" {
return "", err
}
var phoneInfo *UserPhone