github.com/chanxuehong/wechat@v0.0.0-20230222024006-36f0325263cd/mp/card/membercard/userinfo/get.go (about) 1 package userinfo 2 3 import ( 4 "github.com/chanxuehong/wechat/mp/card/code" 5 "github.com/chanxuehong/wechat/mp/core" 6 ) 7 8 type CustomField struct { 9 Name string `json:"name"` 10 Value string `json:"value"` 11 } 12 13 type UserInfo struct { 14 OpenID string `json:"openid"` 15 Nickname string `json:"nickname"` 16 Sex string `json:"sex"` 17 CustomFieldList []CustomField `json:"custom_field_list"` 18 } 19 20 // 拉取会员信息(积分查询)接口 21 func Get(clt *core.Client, id *code.CardItemIdentifier) (info *UserInfo, err error) { 22 var result struct { 23 core.Error 24 UserInfo 25 } 26 27 incompleteURL := "https://api.weixin.qq.com/card/membercard/userinfo/get?access_token=" 28 if err = clt.PostJSON(incompleteURL, id, &result); err != nil { 29 return 30 } 31 32 if result.ErrCode != core.ErrCodeOK { 33 err = &result.Error 34 return 35 } 36 info = &result.UserInfo 37 return 38 }