You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
718 B
29 lines
718 B
package wikeyun
|
|
|
|
import (
|
|
"fmt"
|
|
"go.uber.org/zap"
|
|
"gopkg.in/dtapps/go-library.v3/utils/gohttp"
|
|
)
|
|
|
|
type App struct {
|
|
StoreID int
|
|
AppKey int
|
|
AppSecret string
|
|
ClientIP string
|
|
ZapLog *zap.Logger // 日志服务
|
|
}
|
|
|
|
func (app *App) request(url string, params map[string]interface{}) (resp []byte, err error) {
|
|
// 签名
|
|
sign := app.sign(params)
|
|
// 请求
|
|
requestUrl := fmt.Sprintf("%s?app_key=%d×tamp=%s&client=%s&format=%s&v=%s&sign=%s", url, app.AppKey, sign.Timestamp, sign.Client, sign.Format, sign.V, sign.Sign)
|
|
postForm, err := gohttp.PostForm(requestUrl, params)
|
|
// 日志
|
|
if app.ZapLog != nil {
|
|
app.ZapLog.Sugar().Info(fmt.Sprintf("%s", postForm.Body))
|
|
}
|
|
return postForm.Body, err
|
|
}
|