瀏覽代碼

口袋圈

master
huangjiajun 7 月之前
父節點
當前提交
86f4913565
共有 1 個文件被更改,包括 48 次插入0 次删除
  1. +48
    -0
      kdq/api.go

+ 48
- 0
kdq/api.go 查看文件

@@ -0,0 +1,48 @@
package kdq

import (
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"github.com/syyongx/php2go"
"io/ioutil"
"log"
"net/http"
"net/url"
"time"
)

//口袋圈
func KdqSend(appkey, appSecret, method string, params map[string]string) (string, error) {
url := "https://open.xr876.cn/" + method
now := time.Now().Unix()
param := map[string]string{
"dev_username": appkey,
"timestamp": zhios_third_party_utils.Int64ToStr(now),
}
if params["phone"] != "" {
param["phone"] = params["phone"]
}
if params["userid"] != "" {
param["userid"] = params["userid"]
}
sign := php2go.Md5(appkey + appSecret + zhios_third_party_utils.Int64ToStr(now))
param["sign"] = sign
data, err := Post(url, param)
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)
return res, err
}

Loading…
取消
儲存