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 WxAccessToken
- type WxConfig
- 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 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 MaSetUserStorage = ApiDefaultHostUrl + "/wxa/set_user_storage?appid=%s&signature=%s&openid=%s&sig_method=%s" )
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 WxAccessToken ¶
type WxAccessToken interface { // 获取access_token GetAccessToken() (*AccessToken, error) // access_token是否过期, ture:是 IsAccessTokenExpired() bool // 强制过期access_token ExpireAccessToken() }
type WxConfig ¶
type WxConfig interface { // 获取appId GetAppID() string // 获取密钥 GetSecret() string // 获取access_token GetAccessToken() *AccessToken // 设置access_token SetAccessToken(*AccessToken) }
配置的接口
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) }
http请求,获取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 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.