update
This commit is contained in:
parent
7b2333e3a8
commit
4775c1aa5b
@ -220,10 +220,11 @@ func fetchTokenFromAPI(username, password string) (string, error) {
|
|||||||
fmt.Println(string(reqBodyJson))
|
fmt.Println(string(reqBodyJson))
|
||||||
returnValue, err := http.Post(url, "application/json", bytes.NewBuffer(reqBodyJson))
|
returnValue, err := http.Post(url, "application/json", bytes.NewBuffer(reqBodyJson))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.New("获取token失败")
|
return "", errors.New("获取token失败,无法解析 token URL")
|
||||||
}
|
}
|
||||||
defer returnValue.Body.Close()
|
defer returnValue.Body.Close()
|
||||||
body, _ := io.ReadAll(returnValue.Body)
|
body, _ := io.ReadAll(returnValue.Body)
|
||||||
|
fmt.Println(string(body))
|
||||||
// 解析返回的json数据,判断是否有code字段并且code是否为1,如果是,则获取并返回token
|
// 解析返回的json数据,判断是否有code字段并且code是否为1,如果是,则获取并返回token
|
||||||
var result map[string]interface{}
|
var result map[string]interface{}
|
||||||
json.Unmarshal(body, &result)
|
json.Unmarshal(body, &result)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user