wechat

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2015 License: GPL-2.0 Imports: 19 Imported by: 4

Documentation

Overview

  • 与腾讯服务器的相关交互

*

  • 通过网页授权获取用户基本信息

*

Index

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 GetTempQrUrl

func GetTempQrUrl(expire_seconds int, scene_id int, scene_str string) string

func GetTempTicket

func GetTempTicket(expire_seconds int, scene_id int, scene_str string) string

func GetUserList

func GetUserList()

/ 获取用户列表并报错到redis数据库中 KEY=wx_UserList

func GetUserListInfo

func GetUserListInfo()

/ 获取用户信息列表

func ReceiveMsg

func ReceiveMsg(content string) (r string)

func RegDB

func RegDB()

func UpdateAccessToken

func UpdateAccessToken() (expires_in int, err error)

更新微信的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 MsgType

type MsgType struct {
	MsgType string `xml:"MsgType"`
	Event   string `xml:"Event"`
}

type Ticket

type Ticket struct {
	Ticket         string `json : "ticket"`         //	获取的二维码ticket
	Expire_seconds int    `json : "expire_seconds"` //二维码的有效时间,以秒为单位。最大不超过1800。
	Url            string `json : "url"`
}

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 GetWebAccessToken

func GetWebAccessToken(code string) *WebAccessToken

获取网页端的 AccessToken

func (*WebAccessToken) GetUserInfo

func (this *WebAccessToken) GetUserInfo() *WebUserInfo

获取用户信息

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

Directories

Path Synopsis
* 文件描述: 微信JS-SDK的相关服务 * 创建日期: 2015/3/18 * 作者: ckeyer * 功能: 微信SDK初始化 *
* 文件描述: 微信JS-SDK的相关服务 * 创建日期: 2015/3/18 * 作者: ckeyer * 功能: 微信SDK初始化 *

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL