|
@@ -275,7 +275,7 @@ type TmplMsg struct {
|
|
// nolint
|
|
// nolint
|
|
type ResponseWriter interface {
|
|
type ResponseWriter interface {
|
|
// Get weixin
|
|
// Get weixin
|
|
- GetWeixin() *Weixin
|
|
|
|
|
|
+ GetWeiXin() *Weixin
|
|
GetUserData() interface{}
|
|
GetUserData() interface{}
|
|
// Reply message
|
|
// Reply message
|
|
replyMsg(msg string)
|
|
replyMsg(msg string)
|
|
@@ -300,6 +300,7 @@ type ResponseWriter interface {
|
|
DownloadMediaToFile(mediaId string, filepath string) error
|
|
DownloadMediaToFile(mediaId string, filepath string) error
|
|
UploadMedia(mediaType string, filename string, reader io.Reader) (string, error)
|
|
UploadMedia(mediaType string, filename string, reader io.Reader) (string, error)
|
|
DownloadMedia(mediaId string, writer io.Writer) error
|
|
DownloadMedia(mediaId string, writer io.Writer) error
|
|
|
|
+ GetUserBaseInfo(openid string) (map[string]interface{}, error)
|
|
}
|
|
}
|
|
|
|
|
|
type responseWriter struct {
|
|
type responseWriter struct {
|
|
@@ -1187,7 +1188,7 @@ func (w responseWriter) replyHeader() string {
|
|
}
|
|
}
|
|
|
|
|
|
// Return weixin instance.
|
|
// Return weixin instance.
|
|
-func (w responseWriter) GetWeixin() *Weixin {
|
|
|
|
|
|
+func (w responseWriter) GetWeiXin() *Weixin {
|
|
return w.wx
|
|
return w.wx
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1301,6 +1302,23 @@ func (w responseWriter) UploadMedia(mediaType string, filename string, reader io
|
|
func (w responseWriter) DownloadMedia(mediaID string, writer io.Writer) error {
|
|
func (w responseWriter) DownloadMedia(mediaID string, writer io.Writer) error {
|
|
return w.wx.DownloadMedia(mediaID, writer)
|
|
return w.wx.DownloadMedia(mediaID, writer)
|
|
}
|
|
}
|
|
|
|
+func (rw responseWriter) GetUserBaseInfo(openid string) (map[string]interface{}, error) {
|
|
|
|
+ return rw.wx.GetUserBaseInfo(openid)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//取得用户(关注人)基本信息
|
|
|
|
+func (w *Weixin) GetUserBaseInfo(openid string) (map[string]interface{}, error) {
|
|
|
|
+ bs, err := sendGetRequest(weixinUserInfo+"?openid="+openid+"&lang=zh_CN&access_token=", w.tokenChan)
|
|
|
|
+ if err == nil {
|
|
|
|
+ //log.Println("get userinfo ", string(bs))
|
|
|
|
+ ret := map[string]interface{}{}
|
|
|
|
+ err = json.Unmarshal(bs, &ret)
|
|
|
|
+ return ret, err
|
|
|
|
+ } else {
|
|
|
|
+ log.Println("get userinfo err ", err.Error())
|
|
|
|
+ return nil, err
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
|
|
/*************************************
|
|
/*************************************
|
|
以下为自定义扩展
|
|
以下为自定义扩展
|