Documentation
¶
Overview ¶
微信公众号接口
Index ¶
- Constants
- func CheckSignature(token, timestamp, nonce, signature string) bool
- func CreateJsapiSignature(url, appId, ticket string) (*common.WxJsapiSignature, error)
- func CreateJsapiSignatureBy(appId, secret, url string) (*common.WxJsapiSignature, error)
- func GetAccessToken(appId, secret string) (*common.AccessToken, error)
- type ActionName
- type WxMpChangeOpenid
- type WxMpConfig
- type WxMpConfigImpl
- func (c *WxMpConfigImpl) ExpireTicket(ticketType common.TicketType)
- func (c *WxMpConfigImpl) GetAccessToken() *common.AccessToken
- func (c *WxMpConfigImpl) GetAesKey() string
- func (c *WxMpConfigImpl) GetAppID() string
- func (c *WxMpConfigImpl) GetSecret() string
- func (c WxMpConfigImpl) GetTicket(ticketType common.TicketType) *common.Ticket
- func (c *WxMpConfigImpl) GetToken() string
- func (c *WxMpConfigImpl) GetWxTicket() common.WxTicket
- func (c *WxMpConfigImpl) IsTicketExpired(ticketType common.TicketType) bool
- func (c *WxMpConfigImpl) SetAccessToken(at *common.AccessToken)
- func (c *WxMpConfigImpl) UpdateTicket(ticketType common.TicketType, ticket *common.Ticket)
- type WxMpQrCodeTicket
- type WxMpQrcodeService
- type WxMpQrcodeServiceImpl
- func (r *WxMpQrcodeServiceImpl) QrcodeCreateLastTicket(actionName ActionName, sceneStr string, sceneId, expireSeconds int64) (*WxMpQrCodeTicket, error)
- func (r *WxMpQrcodeServiceImpl) QrcodeCreateTmpTicket(actionName ActionName, sceneStr string, sceneId, expireSeconds int64) (*WxMpQrCodeTicket, error)
- type WxMpService
- type WxMpServiceImpl
- func (s *WxMpServiceImpl) CheckSignature(timestamp, nonce, signature string) bool
- func (s *WxMpServiceImpl) CreateJsapiSignature(url string) (*common.WxJsapiSignature, error)
- func (s *WxMpServiceImpl) ForceGetJsapiTicket(forceRefresh bool) (*common.Ticket, error)
- func (s *WxMpServiceImpl) ForceGetTicket(ticketType common.TicketType, forceRefresh bool) (*common.Ticket, error)
- func (s *WxMpServiceImpl) GetJsapiTicket() (*common.Ticket, error)
- func (s *WxMpServiceImpl) GetTicket(ticketType common.TicketType) (*common.Ticket, error)
- func (s *WxMpServiceImpl) GetWxMpConfig() WxMpConfig
- func (s *WxMpServiceImpl) GetWxMpQrcodeService() WxMpQrcodeService
- func (s *WxMpServiceImpl) GetWxMpUserService() WxMpUserService
- func (s *WxMpServiceImpl) SetWxMpConfig(config WxMpConfig)
- func (s *WxMpServiceImpl) SetWxMpQrcodeService(qrcodeService WxMpQrcodeService)
- func (s *WxMpServiceImpl) SetWxMpUserService(userService WxMpUserService)
- type WxMpUser
- type WxMpUserList
- type WxMpUserQueryParam
- type WxMpUserService
- type WxMpUserServiceImpl
- func (r *WxMpUserServiceImpl) ChangeOpenid(fromAppId string, openidArr ...string) ([]*WxMpChangeOpenid, error)
- func (r *WxMpUserServiceImpl) GetUserInfo(openid string) (*WxMpUser, error)
- func (r *WxMpUserServiceImpl) GetUserInfoBy(openid, lang string) (*WxMpUser, error)
- func (r *WxMpUserServiceImpl) GetUserInfoList(openidArr ...string) ([]*WxMpUser, error)
- func (r *WxMpUserServiceImpl) GetUserInfoListBy(arr []*WxMpUserQueryParam) ([]*WxMpUser, error)
- func (r *WxMpUserServiceImpl) GetUserList(nextOpenid string) (*WxMpUserList, error)
- func (r *WxMpUserServiceImpl) UserUpdateRemark(openid, remark string) error
Constants ¶
View Source
const ( QrScene = "QR_SCENE" QrStrScene = "QR_STR_SCENE" QrLimitScene = "QR_LIMIT_SCENE" QrLimitStrScene = "QR_LIMIT_STR_SCENE" )
Variables ¶
This section is empty.
Functions ¶
func CheckSignature ¶ added in v0.5.0
func CreateJsapiSignature ¶ added in v0.5.0
func CreateJsapiSignature(url, appId, ticket string) (*common.WxJsapiSignature, error)
func CreateJsapiSignatureBy ¶ added in v0.6.2
func CreateJsapiSignatureBy(appId, secret, url string) (*common.WxJsapiSignature, error)
创建调用jsapi时所需要的签名.
func GetAccessToken ¶ added in v0.6.2
func GetAccessToken(appId, secret string) (*common.AccessToken, error)
获取accessToken
Types ¶
type ActionName ¶
type ActionName string
type WxMpChangeOpenid ¶
type WxMpConfig ¶
func NewWxMpConfig ¶ added in v0.6.1
func NewWxMpConfig(appId, secret string) WxMpConfig
type WxMpConfigImpl ¶
type WxMpConfigImpl struct { AccessToken *common.AccessToken Token string AesKey string // contains filtered or unexported fields }
func (*WxMpConfigImpl) ExpireTicket ¶
func (c *WxMpConfigImpl) ExpireTicket(ticketType common.TicketType)
func (*WxMpConfigImpl) GetAccessToken ¶
func (c *WxMpConfigImpl) GetAccessToken() *common.AccessToken
func (*WxMpConfigImpl) GetAesKey ¶
func (c *WxMpConfigImpl) GetAesKey() string
func (*WxMpConfigImpl) GetAppID ¶
func (c *WxMpConfigImpl) GetAppID() string
func (*WxMpConfigImpl) GetSecret ¶
func (c *WxMpConfigImpl) GetSecret() string
func (WxMpConfigImpl) GetTicket ¶
func (c WxMpConfigImpl) GetTicket(ticketType common.TicketType) *common.Ticket
func (*WxMpConfigImpl) GetToken ¶
func (c *WxMpConfigImpl) GetToken() string
func (*WxMpConfigImpl) GetWxTicket ¶ added in v0.6.1
func (c *WxMpConfigImpl) GetWxTicket() common.WxTicket
func (*WxMpConfigImpl) IsTicketExpired ¶
func (c *WxMpConfigImpl) IsTicketExpired(ticketType common.TicketType) bool
func (*WxMpConfigImpl) SetAccessToken ¶
func (c *WxMpConfigImpl) SetAccessToken(at *common.AccessToken)
func (*WxMpConfigImpl) UpdateTicket ¶
func (c *WxMpConfigImpl) UpdateTicket(ticketType common.TicketType, ticket *common.Ticket)
type WxMpQrCodeTicket ¶
type WxMpQrCodeTicket struct { Ticket string `json:"ticket"` ExpireSeconds int `json:"expire_seconds"` // 如果为-1,说明是永久 Url string `json:"url"` }
二维码ticket
type WxMpQrcodeService ¶
type WxMpQrcodeService interface { // 换取临时二维码ticket // 详情请见: https://mp.weixin.qq.com/wiki?action=doc&id=mp1443433542&t=0.9274944716856435 // sceneStr 和 sceneId 二选一就行 QrcodeCreateTmpTicket(actionName ActionName, sceneStr string, sceneId, expireSeconds int64) (*WxMpQrCodeTicket, error) // 换取永久二维码ticket // 详情请见: https://mp.weixin.qq.com/wiki?action=doc&id=mp1443433542&t=0.9274944716856435 QrcodeCreateLastTicket(actionName ActionName, sceneStr string, sceneId, expireSeconds int64) (*WxMpQrCodeTicket, error) }
type WxMpQrcodeServiceImpl ¶
type WxMpQrcodeServiceImpl struct {
// contains filtered or unexported fields
}
func (*WxMpQrcodeServiceImpl) QrcodeCreateLastTicket ¶
func (r *WxMpQrcodeServiceImpl) QrcodeCreateLastTicket(actionName ActionName, sceneStr string, sceneId, expireSeconds int64) (*WxMpQrCodeTicket, error)
func (*WxMpQrcodeServiceImpl) QrcodeCreateTmpTicket ¶
func (r *WxMpQrcodeServiceImpl) QrcodeCreateTmpTicket(actionName ActionName, sceneStr string, sceneId, expireSeconds int64) (*WxMpQrCodeTicket, error)
type WxMpService ¶
type WxMpService interface { common.WxService common.WxJsapi // 获取配置 GetWxMpConfig() WxMpConfig // 设置配置 SetWxMpConfig(WxMpConfig) // 验证消息的确来自微信服务器 CheckSignature(timestamp, nonce, signature string) bool // 获取用户接口 GetWxMpUserService() WxMpUserService // 设置(用户自定义的)用户接口 SetWxMpUserService(WxMpUserService) // 获取二维码接口 GetWxMpQrcodeService() WxMpQrcodeService // 设置(用户自定义的)二维码接口 SetWxMpQrcodeService(WxMpQrcodeService) }
func NewWxMpService ¶
func NewWxMpService(config WxMpConfig) WxMpService
func NewWxMpServiceBy ¶ added in v0.5.0
func NewWxMpServiceBy(appId, secret string) WxMpService
type WxMpServiceImpl ¶
type WxMpServiceImpl struct { common.WxServiceImpl // contains filtered or unexported fields }
func (*WxMpServiceImpl) CheckSignature ¶
func (s *WxMpServiceImpl) CheckSignature(timestamp, nonce, signature string) bool
func (*WxMpServiceImpl) CreateJsapiSignature ¶
func (s *WxMpServiceImpl) CreateJsapiSignature(url string) (*common.WxJsapiSignature, error)
func (*WxMpServiceImpl) ForceGetJsapiTicket ¶
func (s *WxMpServiceImpl) ForceGetJsapiTicket(forceRefresh bool) (*common.Ticket, error)
func (*WxMpServiceImpl) ForceGetTicket ¶
func (s *WxMpServiceImpl) ForceGetTicket(ticketType common.TicketType, forceRefresh bool) (*common.Ticket, error)
func (*WxMpServiceImpl) GetJsapiTicket ¶
func (s *WxMpServiceImpl) GetJsapiTicket() (*common.Ticket, error)
func (*WxMpServiceImpl) GetTicket ¶
func (s *WxMpServiceImpl) GetTicket(ticketType common.TicketType) (*common.Ticket, error)
func (*WxMpServiceImpl) GetWxMpConfig ¶
func (s *WxMpServiceImpl) GetWxMpConfig() WxMpConfig
func (*WxMpServiceImpl) GetWxMpQrcodeService ¶
func (s *WxMpServiceImpl) GetWxMpQrcodeService() WxMpQrcodeService
func (*WxMpServiceImpl) GetWxMpUserService ¶
func (s *WxMpServiceImpl) GetWxMpUserService() WxMpUserService
func (*WxMpServiceImpl) SetWxMpConfig ¶
func (s *WxMpServiceImpl) SetWxMpConfig(config WxMpConfig)
func (*WxMpServiceImpl) SetWxMpQrcodeService ¶ added in v0.5.0
func (s *WxMpServiceImpl) SetWxMpQrcodeService(qrcodeService WxMpQrcodeService)
func (*WxMpServiceImpl) SetWxMpUserService ¶ added in v0.5.0
func (s *WxMpServiceImpl) SetWxMpUserService(userService WxMpUserService)
type WxMpUser ¶
type WxMpUser struct { Subscribe bool `json:"subscribe"` OpenId string `json:"open_id"` Nickname string `json:"nickname"` // 性别描述信息:男、女、未知等. SexDesc string `json:"sex_desc"` // 性别表示:1,2等数字. Sex string `json:"sex"` Language string `json:"language"` City string `json:"city"` Province string `json:"province"` Country string `json:"country"` HeadImgUrl string `json:"head_img_url"` SubscribeTime string `json:"subscribe_time"` // https://mp.weixin.qq.com/cgi-bin/announce?action=getannouncement&announce_id=11513156443eZYea&version=&lang=zh_CN // 只有在将公众号绑定到微信开放平台帐号后,才会出现该字段。 // 另外,在用户未关注公众号时,将不返回用户unionID信息。 // 已关注的用户,开发者可使用“获取用户基本信息接口”获取unionID; // 未关注用户,开发者可使用“微信授权登录接口”并将scope参数设置为snsapi_userinfo,获取用户unionID UnionId string `json:"union_id"` Remark string `json:"remark"` GroupId string `json:"group_id"` TagIds string `json:"tag_ids"` // 用户特权信息,json 数组,如微信沃卡用户为(chinaunicom). Privileges string `json:"privileges"` // subscribe_scene 返回用户关注的渠道来源. // ADD_SCENE_SEARCH 公众号搜索,ADD_SCENE_ACCOUNT_MIGRATION 公众号迁移,ADD_SCENE_PROFILE_CARD 名片分享,ADD_SCENE_QR_CODE 扫描二维码,ADD_SCENEPROFILE LINK 图文页内名称点击,ADD_SCENE_PROFILE_ITEM 图文页右上角菜单,ADD_SCENE_PAID 支付后关注,ADD_SCENE_OTHERS 其他 SubscribeScene string `json:"subscribe_scene"` // 二维码扫码场景(开发者自定义). QrScene string `json:"qr_scene"` // 二维码扫码场景描述(开发者自定义). QrSceneStr string `json:"qr_scene_str"` }
微信用户信息
type WxMpUserList ¶
type WxMpUserQueryParam ¶
func GetWxMpUserQueryParam ¶
func GetWxMpUserQueryParam(openidArr ...string) []*WxMpUserQueryParam
type WxMpUserService ¶
type WxMpUserService interface { // 设置用户备注名 // 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140838&token=&lang=zh_CN UserUpdateRemark(openid, remark string) error // 获取用户基本信息(语言为默认的zh_CN 简体) // 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839&token=&lang=zh_CN GetUserInfo(openid string) (*WxMpUser, error) // 获取用户基本信息指定语言 GetUserInfoBy(openid, lang string) (*WxMpUser, error) // 获取用户基本信息列表 // 开发者可通过该接口来批量获取用户基本信息。最多支持一次拉取100条。 // 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839&token=&lang=zh_CN GetUserInfoList(openidArr ...string) ([]*WxMpUser, error) // 获取用户基本信息列表指定语言 GetUserInfoListBy([]*WxMpUserQueryParam) ([]*WxMpUser, error) // 获取用户列表 // 公众号可通过本接口来获取帐号的关注者列表, // 关注者列表由一串OpenID(加密后的微信号,每个用户对每个公众号的OpenID是唯一的)组成。 // 一次拉取调用最多拉取10000个关注者的OpenID,可以通过多次拉取的方式来满足需求。 // 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140840&token=&lang=zh_CN GetUserList(nextOpenid string) (*WxMpUserList, error) // 微信公众号主体变更迁移用户 openid // 详情请见: http://kf.qq.com/faq/170221aUnmmU170221eUZJNf.html, http://kf.qq.com/faq/1901177NrqMr190117nqYJze.html // fromAppId: 原公众号的 // 一次最多100个 ChangeOpenid(fromAppId string, openidArr ...string) ([]*WxMpChangeOpenid, error) }
type WxMpUserServiceImpl ¶
type WxMpUserServiceImpl struct {
// contains filtered or unexported fields
}
func (*WxMpUserServiceImpl) ChangeOpenid ¶
func (r *WxMpUserServiceImpl) ChangeOpenid(fromAppId string, openidArr ...string) ([]*WxMpChangeOpenid, error)
func (*WxMpUserServiceImpl) GetUserInfo ¶
func (r *WxMpUserServiceImpl) GetUserInfo(openid string) (*WxMpUser, error)
func (*WxMpUserServiceImpl) GetUserInfoBy ¶
func (r *WxMpUserServiceImpl) GetUserInfoBy(openid, lang string) (*WxMpUser, error)
func (*WxMpUserServiceImpl) GetUserInfoList ¶
func (r *WxMpUserServiceImpl) GetUserInfoList(openidArr ...string) ([]*WxMpUser, error)
func (*WxMpUserServiceImpl) GetUserInfoListBy ¶
func (r *WxMpUserServiceImpl) GetUserInfoListBy(arr []*WxMpUserQueryParam) ([]*WxMpUser, error)
func (*WxMpUserServiceImpl) GetUserList ¶
func (r *WxMpUserServiceImpl) GetUserList(nextOpenid string) (*WxMpUserList, error)
func (*WxMpUserServiceImpl) UserUpdateRemark ¶
func (r *WxMpUserServiceImpl) UserUpdateRemark(openid, remark string) error
Click to show internal directories.
Click to hide internal directories.