Documentation ¶
Index ¶
- Constants
- func BodyToMap(b []byte, d string) util.Map
- func ClientCredential(config *Config) util.Map
- func ClientSet(setter ClientSetter, v []interface{}) bool
- func Connect(domain string, uri string) string
- func CredentialGet(v []interface{}) util.Map
- func DomainHost(domain string) string
- func GetClientIP(r *http.Request) string
- func GetServerIP() string
- func KeyMap(at *AccessToken) (util.Map, error)
- func Link(uri string, host ...string) string
- func MustKeyMap(at *AccessToken) util.Map
- func ParseBody(r *http.Response) ([]byte, error)
- func SaveEncodingTo(response Response, path string, t transform.Transformer) error
- func SaveTo(response Response, path string) error
- func WriteJSON(w http.ResponseWriter, status int, obj interface{}) error
- type AccessToken
- func (a *AccessToken) Credentials() util.Map
- func (a *AccessToken) GetRefreshedToken() *Token
- func (a *AccessToken) GetToken() *Token
- func (a *AccessToken) GetTokenWithRefresh() *Token
- func (a *AccessToken) Refresh() *AccessToken
- func (a *AccessToken) RequestToken(credentials string) *Token
- func (a *AccessToken) SetClient(client *Client)
- func (a *AccessToken) SetCredentials(p util.Map) *AccessToken
- func (a *AccessToken) SetToken(token string) *AccessToken
- func (a *AccessToken) SetTokenWithLife(token string, lifeTime time.Time) *AccessToken
- type Base
- type Client
- func (c *Client) Get(url string, query util.Map) Response
- func (c *Client) GetRaw(url string, query util.Map) []byte
- func (c *Client) Post(url string, maps util.Map) Response
- func (c *Client) PostForm(url string, query util.Map, form interface{}) Response
- func (c *Client) PostJSON(url string, query util.Map, json interface{}) Response
- func (c *Client) PostXML(url string, query util.Map, xml interface{}) Response
- func (c *Client) Request(url string, method string, ops util.Map) Response
- func (c *Client) RequestRaw(url string, method string, ops util.Map) []byte
- func (c *Client) Upload(url string, query, multi util.Map) Response
- type ClientGetter
- type ClientSetter
- type Config
- func (c *Config) Check(arr ...string) int
- func (c *Config) DeepGet(strings ...string) interface{}
- func (c *Config) DeepGetD(def string, strings ...string) interface{}
- func (c *Config) Get(s string) interface{}
- func (c *Config) GetArray(key string) []interface{}
- func (c *Config) GetArrayD(key string, d []interface{}) []interface{}
- func (c *Config) GetBool(s string) bool
- func (c *Config) GetBoolD(s string, d bool) bool
- func (c *Config) GetD(s string, d interface{}) interface{}
- func (c *Config) GetInt(s string) int64
- func (c *Config) GetIntD(s string, d int64) int64
- func (c *Config) GetString(s string) string
- func (c *Config) GetStringArray(key string) []string
- func (c *Config) GetStringArrayD(key string, d []string) []string
- func (c *Config) GetStringD(s, d string) string
- func (c *Config) GetSubConfig(s string) *Config
- func (c *Config) GetTree(s string) interface{}
- func (c *Config) Set(k string, v interface{}) *Config
- type CredentialSetter
- type MediaType
- type Message
- type MessageCallback
- type PaymentCallback
- type Response
- type Token
- type URL
- type UserID
- type UserInfo
- type WriteAble
Constants ¶
const ( DataTypeXML = "xml" DataTypeJSON = "json" DataTypeQuery = "query" DataTypeForm = "form_params" DataTypeFile = "file" DataTypeMultipart = "multipart" DataTypeSecurity = "security" )
data types
const ( MPDomain = "https://mp.weixin.qq.com" BaseDomain = "https://api.mch.weixin.qq.com" APIWeixin = "https://api.weixin.qq.com" API2Domain = "https://api2.mch.weixin.qq.com" HKDomain = "https://apihk.mch.weixin.qq.com" USDomain = "https://apius.mch.weixin.qq.com" FileAPIWeixin = "http://file.api.weixin.qq.com" )
domain defines
const AccessTokenExpiresIn = "expires_in"
AccessTokenExpiresIn 过期
const AccessTokenSafeSeconds = 500
AccessTokenSafeSeconds token安全时间
Variables ¶
This section is empty.
Functions ¶
func ClientCredential ¶ added in v1.0.1
ClientCredential ...
func ClientSet ¶ added in v1.0.1
func ClientSet(setter ClientSetter, v []interface{}) bool
ClientSet ...
func KeyMap ¶
func KeyMap(at *AccessToken) (util.Map, error)
KeyMap get accessToken's key,value with map
func MustKeyMap ¶
func MustKeyMap(at *AccessToken) util.Map
MustKeyMap get accessToken's key,value with map when nil or error return nil map
func SaveEncodingTo ¶ added in v1.0.1
func SaveEncodingTo(response Response, path string, t transform.Transformer) error
SaveEncodingTo ...
Types ¶
type AccessToken ¶
AccessToken AccessToken
func NewAccessToken ¶
func NewAccessToken(v ...interface{}) *AccessToken
NewAccessToken NewAccessToken
func (*AccessToken) Credentials ¶ added in v1.0.1
func (a *AccessToken) Credentials() util.Map
Credentials ...
func (*AccessToken) GetRefreshedToken ¶
func (a *AccessToken) GetRefreshedToken() *Token
GetRefreshedToken 获取刷新token
func (*AccessToken) GetTokenWithRefresh ¶
func (a *AccessToken) GetTokenWithRefresh() *Token
GetTokenWithRefresh 重新获取token
func (*AccessToken) RequestToken ¶
func (a *AccessToken) RequestToken(credentials string) *Token
RequestToken 请求获取token
func (*AccessToken) SetClient ¶ added in v1.0.1
func (a *AccessToken) SetClient(client *Client)
SetClient ...
func (*AccessToken) SetCredentials ¶ added in v1.0.1
func (a *AccessToken) SetCredentials(p util.Map) *AccessToken
SetCredentials set request credential
func (*AccessToken) SetToken ¶
func (a *AccessToken) SetToken(token string) *AccessToken
SetToken set string accessToken
func (*AccessToken) SetTokenWithLife ¶
func (a *AccessToken) SetTokenWithLife(token string, lifeTime time.Time) *AccessToken
SetTokenWithLife set string accessToken with life time
type Base ¶
type Base struct { *Config // contains filtered or unexported fields }
Base 基础
func (*Base) AccessToken ¶ added in v1.0.1
func (b *Base) AccessToken() *AccessToken
AccessToken ...
func (*Base) ClearQuota ¶
ClearQuota 公众号的所有api调用(包括第三方帮其调用)次数进行清零 Deprecated: ClearQuota is moved to official_account.Base 公众号调用或第三方平台帮公众号调用对公众号的所有api调用(包括第三方帮其调用)次数进行清零: HTTP请求:POST HTTP调用: https://api.weixin.qq.com/cgi-bin/clear_quota?access_token=ACCESS_TOKEN
func (*Base) GetCallbackIP ¶
GetCallbackIP 请求微信的服务器IP列表 Deprecated: GetCallbackIP is moved to official_account.Base 接口调用请求说明 http请求方式: GET https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=ACCESS_TOKEN
func (*Base) SetAccessToken ¶ added in v1.0.1
func (b *Base) SetAccessToken(accessToken *AccessToken)
SetAccessToken ...
type Client ¶
Client Client
func (*Client) RequestRaw ¶
RequestRaw raw请求
type ClientGetter ¶ added in v1.0.1
type ClientGetter interface {
GetClient() *Client
}
ClientGetter ...
type ClientSetter ¶ added in v1.0.1
type ClientSetter interface {
SetClient(*Client)
}
ClientSetter ...
type Config ¶ added in v1.0.1
type Config struct {
*toml.Tree
}
Config Config Tree
func DefaultConfig ¶ added in v1.0.1
func DefaultConfig() *Config
DefaultConfig get the default config from cache
func LoadConfig ¶ added in v1.0.1
LoadConfig get config tree with file name
func NewConfig ¶ added in v1.0.1
func NewConfig(tree *toml.Tree) *Config
NewConfig create a new null config
func (*Config) Check ¶ added in v1.0.1
Check check all input keys return -1 if all is exist return index when not found
func (*Config) GetStringArray ¶ added in v1.0.1
GetStringArray return string array
func (*Config) GetStringArrayD ¶ added in v1.0.1
GetStringArrayD return string array with default value
func (*Config) GetStringD ¶ added in v1.0.1
GetStringD get string with default value
func (*Config) GetSubConfig ¶ added in v1.0.1
GetSubConfig get sub config from current config
type MediaType ¶
type MediaType string
MediaType MediaType
type Message ¶
type Message struct { message.Message /*message*/ Content message.CDATA `xml:"content"` PicURL message.CDATA `xml:"pic_url"` // 图片链接(由系统生成) MediaID message.CDATA `xml:"media_id"` // 图片消息媒体id,可以调用多媒体文件下载接口拉取数据。 Title message.CDATA `xml:"title"` // 标题 AppID message.CDATA `xml:"app_id"` // 小程序appid PagePath message.CDATA `xml:"page_path"` // 小程序页面路径 ThumbURL message.CDATA `xml:"thumb_url"` // 封面图片的临时cdn链接 ThumbMediaID message.CDATA `xml:"thumb_media_id"` // 封面图片的临时素材id Items []*message.NewItem `xml:"items"` Format message.CDATA `xml:"format"` // 语音格式,如amr,speex等 Recognition message.CDATA `xml:"recognition"` // 语音识别结果,UTF8编码 LocationX float64 `xml:"location_x"` LocationY float64 `xml:"location_y"` Scale int64 `xml:"scale"` Label message.CDATA `xml:"label"` Description message.CDATA `xml:"description"` // 消息描述 URL message.CDATA `xml:"url"` /*event*/ message.Event EventKey message.CDATA `xml:"event_key"` // 事件KEY值,qrscene_为前缀,后面为二维码的参数值 Ticket message.CDATA `xml:"ticket"` // 二维码的ticket,可用来换取二维码图片 Latitude float64 `xml:"latitude"` // 地理位置纬度 Longitude float64 `xml:"longitude"` // 地理位置经度 Precision float64 `xml:"precision"` // 地理位置精度 MenuID message.CDATA `xml:"menu_id"` // 指菜单ID,如果是个性化菜单,则可以通过这个字段,知道是哪个规则的菜单被点击了。 ScanCodeInfo message.ScanCodeInfo `xml:"scan_code_info"` // 扫描信息 SendPicsInfo message.SendPicsInfo `xml:"send_pics_info"` // 发送的图片信息 SendLocationInfo message.SendLocationInfo `xml:"send_location_info"` // 发送的位置信息 Status message.CDATA `xml:"status"` // 发送状态为成功 ExpiredTime int64 `xml:"expired_time"` // 有效期 (整形),指的是时间戳,将于该时间戳认证过期 FailTime int64 `xml:"fail_time"` // 失败发生时间 (整形),时间戳 FailReason message.CDATA `xml:"fail_reason"` // 认证失败的原因 // 名称认证成功(即命名成功) UniqID message.CDATA `xml:"uniq_id"` PoiID message.CDATA `xml:"poi_id"` Result message.CDATA `xml:"result"` Msg message.CDATA `xml:"msg"` SessionFrom message.CDATA `xml:"session_from"` OrderID message.CDATA `xml:"order_id"` OrderStatus int64 `xml:"order_status"` ProductID message.CDATA `xml:"product_id"` SkuInfo message.CDATA `xml:"sku_info"` }
Message 回调消息结构
type MessageCallback ¶
MessageCallback 消息回调函数定义
type Token ¶
type Token struct { // AccessToken is the accessToken that authorizes and authenticates // the requests. AccessToken string `json:"access_token"` // RefreshToken is a accessToken that's used by the application // (as opposed to the user) to refresh the access accessToken // if it expires. RefreshToken string `json:"refresh_token"` // Expiry is the optional expiration time of the access accessToken. // // If zero, TokenSource implementations will reuse the same // accessToken forever and RefreshToken or equivalent // mechanisms for that TokenSource will not be used. ExpiresIn int64 `json:"expires_in"` // wechat openid OpenID string `json:"openid"` // wechat scope Scope string `json:"scope"` // Raw optionally contains extra metadata from the server // when updating a accessToken. Raw interface{} }
Token represents the credentials used to authorize the requests to access protected resources on the OAuth 2.0 provider's backend.
This type is a mirror of oauth2.Token and exists to break an otherwise-circular dependency. Other internal packages should convert this Token into an oauth2.Token before use.
func ParseToken ¶
ParseToken parse accessToken from string
func (*Token) SetExpiresIn ¶
SetExpiresIn set expires time
type URL ¶
type URL struct { *Config // contains filtered or unexported fields }
URL URL
func (*URL) AccessToken ¶ added in v1.0.1
func (url *URL) AccessToken() *AccessToken
AccessToken ...
func (*URL) SetAccessToken ¶ added in v1.0.1
func (url *URL) SetAccessToken(accessToken *AccessToken)
SetAccessToken ...
func (*URL) ShortURL ¶
ShortURL 转换短链接 https://apihk.mch.weixin.qq.com/tools/shorturl (建议接入点:东南亚) https://apius.mch.weixin.qq.com/tools/shorturl (建议接入点:其它) https://api.mch.weixin.qq.com/tools/shorturl (建议接入点:中国国内) 请求参数 URL链接 long_url 是 String(512、 weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX 需要转换的URL,签名用原串,传输需URLencode 返回结果 返回状态码 return_code 是 String(16) SUCCESS/FAIL URL链接 short_url 是 String(64) weixin://wxpay/s/XXXXXX 转换后的URL
type UserInfo ¶
type UserInfo struct { City string `json:"city"` Country string `json:"country"` HeadImgURL string `json:"headimgurl"` Language string `json:"language"` Nickname string `json:"nickname"` Openid string `json:"openid"` Privilege []string `json:"privilege"` Province string `json:"province"` Sex uint `json:"sex"` Subscribe int `json:"subscribe"` SubscribeTime uint32 `json:"subscribe_time"` UnionID string `json:"unionid"` Remark string `json:"remark"` GroupID int `json:"groupid"` TagIDList []int `json:"tagid_list"` SubscribeScene string `json:"subscribe_scene"` QrScene int `json:"qr_scene"` QrSceneStr string `json:"qr_scene_str"` }
UserInfo UserInfo