parent
9fbf6ba6ca
commit
efe77317be
@ -0,0 +1,9 @@
|
|||||||
|
package wechatunion
|
||||||
|
|
||||||
|
const (
|
||||||
|
apiUrl = "https://api.weixin.qq.com/union"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
logTable = "wechatunion"
|
||||||
|
)
|
@ -1,27 +0,0 @@
|
|||||||
package wechatunion
|
|
||||||
|
|
||||||
// Params 请求参数
|
|
||||||
type Params map[string]interface{}
|
|
||||||
|
|
||||||
func NewParams() Params {
|
|
||||||
p := make(Params)
|
|
||||||
return p
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) NewParamsWith(params ...Params) Params {
|
|
||||||
p := make(Params)
|
|
||||||
for _, v := range params {
|
|
||||||
p.SetParams(v)
|
|
||||||
}
|
|
||||||
return p
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p Params) Set(key string, value interface{}) {
|
|
||||||
p[key] = value
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p Params) SetParams(params Params) {
|
|
||||||
for key, value := range params {
|
|
||||||
p[key] = value
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,35 @@
|
|||||||
|
package wechatunion
|
||||||
|
|
||||||
|
import "go.dtapp.net/library/utils/gorequest"
|
||||||
|
|
||||||
|
// 请求
|
||||||
|
func (c *Client) request(url string, params map[string]interface{}, method string) (gorequest.Response, error) {
|
||||||
|
|
||||||
|
// 创建请求
|
||||||
|
client := c.client
|
||||||
|
|
||||||
|
// 设置请求地址
|
||||||
|
client.SetUri(url)
|
||||||
|
|
||||||
|
// 设置请求方式
|
||||||
|
client.SetMethod(method)
|
||||||
|
|
||||||
|
// 设置FORM格式
|
||||||
|
client.SetContentTypeForm()
|
||||||
|
|
||||||
|
// 设置参数
|
||||||
|
client.SetParams(params)
|
||||||
|
|
||||||
|
// 发起请求
|
||||||
|
request, err := client.Request()
|
||||||
|
if err != nil {
|
||||||
|
return gorequest.Response{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 日志
|
||||||
|
if c.logStatus == true {
|
||||||
|
go c.postgresqlLog(request)
|
||||||
|
}
|
||||||
|
|
||||||
|
return request, err
|
||||||
|
}
|
Loading…
Reference in new issue