|
- package wph
-
- import (
- "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/comm"
- zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
- "fmt"
- "github.com/syyongx/php2go"
- "strings"
- "time"
- )
-
- //func SendGet(serviceMethod, method string, serviceParam map[string]string, param string) (string, error) {
- // serviceParamNew := map[string]string{
- // "service": serviceMethod, //服务名称
- // "method": method, //方法名称
- // "version": "1.0.0", //版本号
- // "timestamp": zhios_third_party_utils.Int64ToStr(time.Now().Unix()),
- // "format": "json",
- // "appKey": serviceParam["key"],
- // }
- // if serviceParam["token"] != "" {
- // serviceParamNew["accessToken"] = serviceParam["token"]
- // }
- // sortParam := comm.KsortToStr(serviceParamNew)
- // str := ""
- // for _, v := range sortParam {
- // str += v + serviceParamNew[v]
- // }
- // str += param
- // serviceParamNew["sign"] = strings.ToUpper(comm.HmacMd5(serviceParam["secret"], str))
- // url := "https://vop.vipapis.com"
- // for k, v := range serviceParamNew {
- // if strings.Contains(url, "?") == false {
- // url += "?" + k + "=" + php2go.URLEncode(v)
- // }
- // }
- // get, err := zhios_third_party_utils.CurlGet(url, nil)
- // fmt.Println(string(get))
- // fmt.Println(err)
- // return string(get), err
- //}
- func SendPost(serviceMethod, method string, serviceParam map[string]string, param string) (string, error) {
- serviceParamNew := map[string]string{
- "service": serviceMethod, //服务名称
- "method": method, //方法名称
- "version": "1.0.0", //版本号
- "timestamp": zhios_third_party_utils.Int64ToStr(time.Now().Unix()),
- "format": "json",
- "appKey": serviceParam["key"],
- }
- if serviceParam["token"] != "" {
- serviceParamNew["accessToken"] = serviceParam["token"]
- }
- sortParam := comm.KsortToStr(serviceParamNew)
- str := ""
- for _, v := range sortParam {
- str += v + serviceParamNew[v]
- }
- str += param
- fmt.Println(str)
- serviceParamNew["sign"] = strings.ToUpper(comm.HmacMd5(serviceParam["secret"], str))
- fmt.Println(serviceParamNew["sign"])
-
- url := "https://vop.vipapis.com"
- for k, v := range serviceParamNew {
- if strings.Contains(url, "?") == false {
- url += "?" + k + "=" + php2go.URLEncode(v)
- } else {
- url += "&" + k + "=" + php2go.URLEncode(v)
- }
- }
- fmt.Println(url)
- // 读取响应体
- responseData, err := zhios_third_party_utils.CurlPost(url, param, nil)
-
- fmt.Println(string(responseData))
- fmt.Println(err)
- return string(responseData), err
- }
|