Documentation ¶
Index ¶
- Constants
- type AccessToken
- type Err
- type ErrMsg
- type Service
- type ServiceImpl
- func (s *ServiceImpl) Get(url string, args ...interface{}) ([]byte, error)
- func (s *ServiceImpl) GetFor(v interface{}, url string, args ...interface{}) error
- func (s *ServiceImpl) Post(url string, contentType string, data interface{}, args ...interface{}) ([]byte, error)
- func (s *ServiceImpl) PostFor(v interface{}, url string, contentType string, data interface{}, ...) error
- type Ticket
- type TicketType
- type WxAccessToken
- type WxConfig
- type WxJsapi
- type WxJsapiSignature
- type WxService
- type WxServiceImpl
- func (s *WxServiceImpl) ExpireAccessToken()
- func (s *WxServiceImpl) ForceGetAccessToken(forceRefresh bool) (*AccessToken, error)
- func (s *WxServiceImpl) Get(url string, args ...interface{}) ([]byte, error)
- func (s *WxServiceImpl) GetAccessToken() (*AccessToken, error)
- func (s *WxServiceImpl) GetFor(v interface{}, url string, args ...interface{}) error
- func (s *WxServiceImpl) GetWxConfig() WxConfig
- func (s *WxServiceImpl) IsAccessTokenExpired() bool
- func (s *WxServiceImpl) Post(url string, contentType string, data interface{}, args ...interface{}) ([]byte, error)
- func (s *WxServiceImpl) PostFor(v interface{}, url string, contentType string, data interface{}, ...) error
- func (s *WxServiceImpl) SetHttpService(service Service)
- func (s *WxServiceImpl) SetWxConfig(config WxConfig)
- type WxTicket
- type WxTicketImpl
- type XmlServiceImpl
- func (s *XmlServiceImpl) Get(url string, args ...interface{}) ([]byte, error)
- func (s *XmlServiceImpl) GetFor(v interface{}, url string, args ...interface{}) error
- func (s *XmlServiceImpl) Post(url string, contentType string, data interface{}, args ...interface{}) ([]byte, error)
- func (s *XmlServiceImpl) PostFor(v interface{}, url string, contentType string, data interface{}, ...) error
Constants ¶
View Source
const ( ApiDefaultHostUrl = "https://api.weixin.qq.com" MpDefaultHostUrl = "https://mp.weixin.qq.com" OpenDefaultHostUrl = "https://open.weixin.qq.com" AccessTokenUrl = ApiDefaultHostUrl + "/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s" ApiSuffix = "?access_token=%s" Success = "SUCCESS" Fail = "FAIL" )
common
View Source
const ( MaSessionInfoUrl = ApiDefaultHostUrl + "/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code" MaQrcodeUrl = ApiDefaultHostUrl + "/cgi-bin/wxaapp/createwxaqrcode" + ApiSuffix MaQrWxaCodeUrl = ApiDefaultHostUrl + "/wxa/getwxacode" + ApiSuffix MaQrCodeUnlimitedUrl = ApiDefaultHostUrl + "/wxa/getwxacodeunlimit" + ApiSuffix MaGetPaidUnionIdUrl = ApiDefaultHostUrl + "/wxa/getpaidunionid" + ApiSuffix MaSetUserStorage = ApiDefaultHostUrl + "/wxa/set_user_storage?appid=%s&signature=%s&openid=%s&sig_method=%s" MaGetPubTemplateTitleListUrl = ApiDefaultHostUrl + "/wxaapi/newtmpl/getpubtemplatetitles" + ApiSuffix MaGetPubTemplateKeyWordsByIdUrl = ApiDefaultHostUrl + "/wxaapi/newtmpl/getpubtemplatekeywords" + ApiSuffix MaTemplateListUrl = ApiDefaultHostUrl + "/wxaapi/newtmpl/gettemplate" + ApiSuffix MaGetCategoryUrl = ApiDefaultHostUrl + "/wxaapi/newtmpl/getcategory" + ApiSuffix MaTemplateDelUrl = ApiDefaultHostUrl + "/wxaapi/newtmpl/deltemplate" + ApiSuffix MaTemplateAddUrl = ApiDefaultHostUrl + "/wxaapi/newtmpl/addtemplate" + ApiSuffix MaSubscribeMsgSendUrl = ApiDefaultHostUrl + "/cgi-bin/message/subscribe/send" + ApiSuffix MaUniformMsgSendUrl = ApiDefaultHostUrl + "/cgi-bin/message/wxopen/template/uniform_send" + ApiSuffix MaKefuMessageSendUrl = ApiDefaultHostUrl + "/cgi-bin/message/custom/send" + ApiSuffix MaUpdatableMsgSendUrl = ApiDefaultHostUrl + "/cgi-bin/message/wxopen/updatablemsg/send" + ApiSuffix MaActivityIdCreateUrl = ApiDefaultHostUrl + "/cgi-bin/message/wxopen/activityid/create" + ApiSuffix MaCreateRoom = ApiDefaultHostUrl + "/wxaapi/broadcast/room/create" + ApiSuffix MaEditRoom = ApiDefaultHostUrl + "/wxaapi/broadcast/room/editroom" + ApiSuffix MaGetLiveInfo = ApiDefaultHostUrl + "/wxa/business/getliveinfo" + ApiSuffix MaAddGoods = ApiDefaultHostUrl + "/wxaapi/broadcast/room/addgoods" + ApiSuffix )
ma
View Source
const ( MpGetTicketUrl = ApiDefaultHostUrl + "/cgi-bin/ticket/getticket" + ApiSuffix + "&type=" MpQrcodeUrl = ApiDefaultHostUrl + "/cgi-bin/qrcode/create" + ApiSuffix MpUserUpdateRemarkUrl = ApiDefaultHostUrl + "/cgi-bin/user/info/updateremark" + ApiSuffix MpUserInfoUrl = ApiDefaultHostUrl + "/cgi-bin/user/info" + ApiSuffix + "&openid=%s&lang=%s" MpUserGetUrl = ApiDefaultHostUrl + "/cgi-bin/user/get" + ApiSuffix + "&next_openid=" MpUserInfoBatchGetUrl = ApiDefaultHostUrl + "/cgi-bin/user/info/batchget" + ApiSuffix MpUserChangeOpenidUrl = ApiDefaultHostUrl + "/cgi-bin/changeopenid" )
mp
View Source
const ( PayDefaultPayBaseUrl = "https://api.mch.weixin.qq.com" PayUnifiedOrder = "/pay/unifiedorder" PayCloseOrder = "/pay/closeorder" PayQueryOrder = "/pay/orderquery" PayGetSandboxSignKey = "https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey" PayRefundUrl = "/secapi/pay/refund" PayRefundUrlV2 = "/secapi/pay/refundv2" PayRefundSandboxUrl = "/pay/refund" PayRefundSandboxUrlV2 = "/pay/refundv2" PayQueryRefundUrl = "/pay/refundquery" PayQueryRefundUrlV2 = "/pay/refundqueryv2" EntPayUrl = "/mmpaymkttransfers/promotion/transfers" EntPayQueryUrl = "/mmpaymkttransfers/gettransferinfo" EntPayBankUrl = "/mmpaysptrans/pay_bank" EntPayQueryBankUrl = "/mmpaysptrans/query_bank" EntSendEnterpriseRedPackUrl = "/mmpaymkttransfers/sendworkwxredpack" EntQueryEnterpriseRedPackUrl = "/mmpaymkttransfers/queryworkwxredpack" )
pay
View Source
const ( PostXmlContentType = "application/xml; charset=utf-8" PostJsonContentType = "application/json; charset=utf-8" )
http header
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶
type AccessToken struct { Err AccessToken string `json:"access_token"` ExpiresIn uint64 `json:"expires_in"` Time time.Time `json:"time"` }
小程序access_token
type Service ¶
type Service interface { // 执行Get请求 Get(url string, args ...interface{}) ([]byte, error) // 执行Post请求 Post(url string, contentType string, data interface{}, args ...interface{}) ([]byte, error) // Get 执行Get请求并将结果转成对象 GetFor(v interface{}, url string, args ...interface{}) error // Post 执行Post请求并将结果转成对象 PostFor(v interface{}, url string, contentType string, data interface{}, args ...interface{}) error }
http请求接口
func NewService ¶
func NewService() Service
func NewServiceFor ¶ added in v0.2.0
func NewXmlService ¶ added in v0.2.0
func NewXmlService() Service
func NewXmlServiceFor ¶ added in v0.2.0
type ServiceImpl ¶
type ServiceImpl struct {
// contains filtered or unexported fields
}
http请求默认实现(json传参)
func (*ServiceImpl) Get ¶
func (s *ServiceImpl) Get(url string, args ...interface{}) ([]byte, error)
func (*ServiceImpl) GetFor ¶
func (s *ServiceImpl) GetFor(v interface{}, url string, args ...interface{}) error
type Ticket ¶ added in v0.6.1
type Ticket struct { Err Ticket string `json:"ticket"` ExpiresIn uint64 `json:"expires_in"` Time time.Time `json:"time"` Type string `json:"type"` }
授权页ticket
type TicketType ¶ added in v0.6.1
type TicketType string
ticket类型
const ( JSAPI TicketType = "jsapi" SDK TicketType = "2" WxCard TicketType = "wx_card" )
type WxAccessToken ¶
type WxAccessToken interface { // 获取access_token GetAccessToken() (*AccessToken, error) // access_token是否过期, ture:是 IsAccessTokenExpired() bool // 强制过期access_token ExpireAccessToken() }
access_token接口
type WxConfig ¶
type WxConfig interface { // 获取appId GetAppID() string // 获取密钥 GetSecret() string // 获取access_token GetAccessToken() *AccessToken // 设置access_token SetAccessToken(*AccessToken) // 获取Ticket GetWxTicket() WxTicket }
配置的接口
type WxJsapi ¶ added in v0.6.1
type WxJsapi interface { // 获得jsapi_ticket,不强制刷新jsapi_ticket. GetJsapiTicket() (*Ticket, error) /* 获得jsapi_ticket. 获得时会检查jsapiToken是否过期,如果过期了,那么就刷新一下,否则就什么都不干 详情请见:http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN */ ForceGetJsapiTicket(bool) (*Ticket, error) // 获得ticket,不强制刷新ticket. GetTicket(TicketType) (*Ticket, error) // 获得时会检查 Token是否过期,如果过期了,那么就刷新一下,否则就什么都不干 ForceGetTicket(ticketType TicketType, forceRefresh bool) (*Ticket, error) /* 创建调用jsapi时所需要的签名. 详情请见:http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115&token=&lang=zh_CN */ CreateJsapiSignature(url string) (*WxJsapiSignature, error) }
type WxJsapiSignature ¶ added in v0.6.1
type WxJsapiSignature struct { AppId string `json:"app_id"` NonceStr string `json:"nonce_str"` Timestamp string `json:"timestamp"` Url string `json:"url"` Signature string `json:"signature"` }
jspai signature.
func CreateJsapiSignature ¶ added in v0.6.1
func CreateJsapiSignature(url, appId, ticket string) (*WxJsapiSignature, error)
type WxService ¶
type WxService interface { Service // 获取access_token GetAccessToken() (*AccessToken, error) // 是否强制获取access_token ForceGetAccessToken(forceRefresh bool) (*AccessToken, error) // 配置读取 GetWxConfig() WxConfig // 配置设置 SetWxConfig(WxConfig) // 设置http请求方式 SetHttpService(Service) }
wxAPI,获取accessToken,配置管理
type WxServiceImpl ¶
type WxServiceImpl struct {
// contains filtered or unexported fields
}
http请求默认实现
func (*WxServiceImpl) ExpireAccessToken ¶
func (s *WxServiceImpl) ExpireAccessToken()
func (*WxServiceImpl) ForceGetAccessToken ¶
func (s *WxServiceImpl) ForceGetAccessToken(forceRefresh bool) (*AccessToken, error)
func (*WxServiceImpl) Get ¶
func (s *WxServiceImpl) Get(url string, args ...interface{}) ([]byte, error)
func (*WxServiceImpl) GetAccessToken ¶
func (s *WxServiceImpl) GetAccessToken() (*AccessToken, error)
func (*WxServiceImpl) GetFor ¶
func (s *WxServiceImpl) GetFor(v interface{}, url string, args ...interface{}) error
func (*WxServiceImpl) GetWxConfig ¶
func (s *WxServiceImpl) GetWxConfig() WxConfig
func (*WxServiceImpl) IsAccessTokenExpired ¶
func (s *WxServiceImpl) IsAccessTokenExpired() bool
func (*WxServiceImpl) Post ¶
func (s *WxServiceImpl) Post(url string, contentType string, data interface{}, args ...interface{}) ([]byte, error)
func (*WxServiceImpl) PostFor ¶
func (s *WxServiceImpl) PostFor(v interface{}, url string, contentType string, data interface{}, args ...interface{}) error
func (*WxServiceImpl) SetHttpService ¶
func (s *WxServiceImpl) SetHttpService(service Service)
func (*WxServiceImpl) SetWxConfig ¶
func (s *WxServiceImpl) SetWxConfig(config WxConfig)
type WxTicket ¶ added in v0.6.1
type WxTicket interface { // 获取Ticket GetTicket(TicketType) *Ticket // 更新Ticket UpdateTicket(TicketType, *Ticket) // Ticket是否过期 IsTicketExpired(TicketType) bool // 直接过期Ticket ExpireTicket(TicketType) }
type WxTicketImpl ¶ added in v0.6.1
func (*WxTicketImpl) ExpireTicket ¶ added in v0.6.1
func (c *WxTicketImpl) ExpireTicket(ticketType TicketType)
func (*WxTicketImpl) GetTicket ¶ added in v0.6.1
func (c *WxTicketImpl) GetTicket(ticketType TicketType) *Ticket
func (*WxTicketImpl) IsTicketExpired ¶ added in v0.6.1
func (c *WxTicketImpl) IsTicketExpired(ticketType TicketType) bool
func (*WxTicketImpl) UpdateTicket ¶ added in v0.6.1
func (c *WxTicketImpl) UpdateTicket(ticketType TicketType, ticket *Ticket)
type XmlServiceImpl ¶ added in v0.2.0
type XmlServiceImpl struct {
// contains filtered or unexported fields
}
http请求默认实现(xml传参)
func (*XmlServiceImpl) Get ¶ added in v0.2.0
func (s *XmlServiceImpl) Get(url string, args ...interface{}) ([]byte, error)
func (*XmlServiceImpl) GetFor ¶ added in v0.2.0
func (s *XmlServiceImpl) GetFor(v interface{}, url string, args ...interface{}) error
Click to show internal directories.
Click to hide internal directories.