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.
go-library/service/eastiot/app.go

29 lines
588 B

3 years ago
package eastiot
import (
3 years ago
"gopkg.in/dtapps/go-library.v2/utils/gohttp"
3 years ago
"net/http"
"time"
)
type App struct {
AppID string
ApiKey string
}
func (app *App) request(url string, params map[string]interface{}, method string) ([]byte, error) {
// 公共参数
params["appId"] = app.AppID
params["timeStamp"] = time.Now().Unix()
// 签名
params["sign"] = app.getSign(app.ApiKey, params)
// 请求
if method == http.MethodGet {
get, err := gohttp.Get(url, params)
return get.Body, err
} else {
postJson, err := gohttp.PostForm(url, params)
return postJson.Body, err
}
}