Compare commits

...

2 Commits

Author SHA1 Message Date
jiangyong e87107462a Merge branch 'master' of git.u8t.cn:open/gosdk 2025-09-24 13:35:16 +08:00
jiangyong a157189aef GetUserInfoByJsCode 2025-09-24 13:35:10 +08:00
1 changed files with 3 additions and 0 deletions

View File

@ -39,6 +39,9 @@ func (o *MpSdk) GetUserInfoByJsCode(code string) (*UserInfo, error) {
userInfo := new(UserInfo)
g := gjson.ParseBytes(body)
if g.Get("errcode").Int() != 0 {
return nil, errors.New(string(body))
}
userInfo.Openid = g.Get("openid").String()
userInfo.Unionid = g.Get("unionid").String()
return userInfo, nil