微信相关接口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.2 KiB

package wechat
import (
"errors"
"fmt"
)
type MpUserInfo struct {
Subscribe int `json:"subscribe"`
Openid string `json:"openid"`
Language string `json:"language"`
SubscribeTime int `json:"subscribe_time"`
Unionid string `json:"unionid"`
Remark string `json:"remark"`
Groupid int `json:"groupid"`
TagidList interface{} `json:"tagid_list"`
SubscribeScene string `json:"subscribe_scene"`
QrScene int `json:"qr_scene"`
QrSceneStr string `json:"qr_scene_str"`
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
}
/**
* 公众号获取用户基本信息(UnionID机制)
*/
func GetMpUserInfo(access_token, openid string, lang ...string) (MpUserInfo, error) {
var data MpUserInfo
var language string = "zh_CN"
if len(lang) > 0 {
language = lang[0]
}
url := fmt.Sprintf(MP_USERINFO_API, access_token, openid, language)
data_byte, err := SendHttp("GET", url, nil)
if err != nil {
return data, err
}
err = json.Unmarshal(data_byte, &data)
if data.Errcode != 0 {
return data, errors.New(data.Errmsg)
}
return data, err
}