|
- package kdq
-
- import (
- zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
- "fmt"
- "github.com/syyongx/php2go"
- "io/ioutil"
- "log"
- "net/http"
- "net/url"
- "time"
- )
-
- //口袋圈
- func KdqSend(appkey, appSecret, method string, params map[string]interface{}) (string, error) {
- url := "http://open.xr876.cn/" + method
- now := time.Now().Unix()
- params["dev_username"] = appkey
- params["timestamp"] = zhios_third_party_utils.Int64ToStr(now)
- sign := php2go.Md5(appkey + appSecret + zhios_third_party_utils.Int64ToStr(now))
- params["sign"] = sign
- data, err := zhios_third_party_utils.CurlPost(url, zhios_third_party_utils.SerializeStr(params), nil)
- fmt.Println(string(data))
- return string(data), err
- }
- func Post(urls string, param map[string]string) ([]byte, error) {
- // 设置表单数据
- data := url.Values{}
- for k, v := range param {
- data.Set(k, v)
- }
-
- // 构建请求
- resp, err := http.PostForm(urls, data)
- if err != nil {
- log.Fatal(err)
- return nil, err
- }
- defer resp.Body.Close()
- res, err := ioutil.ReadAll(resp.Body)
- fmt.Println(string(res))
- return res, err
- }
|