Documentation ¶
Overview ¶
- 与腾讯服务器的相关交互
*
- 通过网页授权获取用户基本信息
*
Index ¶
- Constants
- func AutoGetAccessToken()
- func GetAccessToken() string
- func GetTempQrUrl(expire_seconds int, scene_id int, scene_str string) string
- func GetTempTicket(expire_seconds int, scene_id int, scene_str string) string
- func GetUserList()
- func GetUserListInfo()
- func ReceiveMsg(content string) (r string)
- func RegDB()
- func UpdateAccessToken() (expires_in int, err error)
- type AccessToken
- type MsgType
- type Ticket
- type WXOpenIDList
- type WXUserInfo
- type WXUserList
- type WX_AMR
- type WebAccessToken
- type WebUserInfo
Constants ¶
View Source
const (
// redis中微信 AccessToken 的key
REDIS_KEY_WC_ACCESS_TOKEN = "wx_AccessToken"
)
Variables ¶
This section is empty.
Functions ¶
func AutoGetAccessToken ¶
func AutoGetAccessToken()
func GetAccessToken ¶
func GetAccessToken() string
func ReceiveMsg ¶
func UpdateAccessToken ¶
更新微信的AccessToken到Redis中 key=REDIS_KEY_WC_ACCESS_TOKEN
Types ¶
type AccessToken ¶
type AccessToken struct { Access_token string `json: "access_token"` Expires_in int64 `json:"expires_in"` }
func (*AccessToken) Decode ¶
func (this *AccessToken) Decode(jsonstr []byte) error
type WXOpenIDList ¶
type WXOpenIDList struct {
Openid []string `json:openid`
}
type WXUserInfo ¶
type WXUserInfo struct { Id int64 `json:"-"` Subscribe int `json:"subscribe"` // 用户是否订阅该公众号标识 Openid string `json:"openid"` // 用户的标识,对当前公众号唯一 Nickname string `json:"nickname"` // 用户的昵称 Sex int `json:"sex"` // 用户的性别,值为1时是男性,值为2时是女性 City string `json:"city"` // 用户所在城市 Country string `json:"country"` // 用户所在国家 Province string `json:"province"` // 用户所在省份 Language string `json:"language"` // 用户的语言,简体中文为zh_CN Headimgurl string `json:"headimgurl"` // 用户头像 Subscribe_time int64 `json:"subscribe_time"` // 用户关注时间,为时间戳 Unionid int `json:"unionid"` // 只有在用户将公众号绑定到微信开放平台帐号后,才会出现该字段。 }
func GetUserInfo ¶
func GetUserInfo(openid string) (this *WXUserInfo)
/ 获取用户基本信息,并保存到mysql 表tb_wx_user_info 中
type WXUserList ¶
type WXUserList struct { Total int `json:total` Count int `json:count` Data WXOpenIDList `json:data` Next_openid string `json:next_openid` }
type WX_AMR ¶
type WX_AMR struct { Id int64 ToUserName string `xml : "ToUserName"` //开发者微信号 FromUserName string `xml : "FromUserName"` //发送方帐号(一个OpenID) CreateTime string `xml : "CreateTime"` //消息创建时间 (整型) MsgType string `xml : "MsgType"` //语音为voice MediaID string `xml : "MediaID"` //语音消息媒体id,可以调用多媒体文件下载接口拉取该媒体 Format string `xml : "Format"` //语音格式:amr Recognition string `xml : "Recognition"` //语音识别结果,UTF8编码 MsgID int64 `xml : "MsgID"` //消息id,64位整型 }
type WebAccessToken ¶
type WebAccessToken struct { Access_token string `json:"access_token"` Expires_in int `json:"expires_in"` Refresh_token string `json:"refresh_token"` Openid string `json:"openid"` Scope string `json:"scope"` }
func (*WebAccessToken) RefreshAccessToken ¶
func (this *WebAccessToken) RefreshAccessToken()
刷新网页端 AccessToken
type WebUserInfo ¶
type WebUserInfo struct { Id int64 Openid string `json:"openid"` // 用户的唯一标识 Nickname string `json:"nickname"` // 用户昵称 Sex int `json:"sex"` // 用户的性别,值为1时是男性,值为2时是女性,值为0时是未知 Province string `json:"province"` // 用户个人资料填写的省份 City string `json:"city"` // 普通用户个人资料填写的城市 Country string `json:"country"` // 国家,如中国为CN Headimgurl string `json:"headimgurl"` // 用户头像,最后一个数值代表正方形头像大小 Privilege []string `orm:"-"` // 用户特权信息,json 数组,如微信沃卡用户为(chinaunicom) Unionid int64 `json:"unionid"` // }
func (*WebUserInfo) Insert ¶
func (this *WebUserInfo) Insert() error
Click to show internal directories.
Click to hide internal directories.