This commit is contained in:
邹宗楠
2022-12-06 11:22:10 +08:00
7 changed files with 23 additions and 19 deletions

View File

@@ -172,20 +172,24 @@ func (a *API) SNSGetUserPhone(jsCode string) (string, error) {
// 获取小程序短连接CBRetrieveToken
func (a *API) MiniProgramSortLink() (string, error) {
weChatToken := ""
if token := a.CBGetToken(); token == "" {
token := a.CBGetToken()
if token == "" {
newToken, err := a.CBRetrieveToken()
if err != nil {
return "", err
}
weChatToken = newToken.AccessToken
} else {
weChatToken = token
}
parmaJson := map[string]interface{}{
"access_token": weChatToken,
}
bodyJson := map[string]interface{}{
"access_token ": weChatToken,
"expire_type ": 0,
//"access_token ": weChatToken,
"expire_type ": 1,
"expire_time": 1,
}
body, _ := json.Marshal(bodyJson)
result, err := a.AccessAPI("wxa/generate_urllink", parmaJson, string(body))

View File

@@ -73,7 +73,7 @@ func isSNSAction(action string) bool {
}
func (a *API) AccessAPI(action string, params map[string]interface{}, body string) (retVal map[string]interface{}, err error) {
if params != nil && body != "" {
if params == nil && body == "" {
panic("params and body can not all be empty")
}
params2 := make(map[string]interface{})