第三方api接口
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.

api.go 979 B

1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627
  1. package express
  2. import (
  3. zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
  4. "github.com/syyongx/php2go"
  5. "strings"
  6. "time"
  7. )
  8. func Send(mustParam map[string]string, apiCode string, data map[string]interface{}) (string, error) {
  9. url := mustParam["express_url"]
  10. key := mustParam["express_key"]
  11. clientId := mustParam["express_client_id"]
  12. timestamp := zhios_third_party_utils.Int64ToStr(time.Now().UnixNano() / 1e6)
  13. param := map[string]interface{}{
  14. "clientId": clientId,
  15. "timestamp": timestamp,
  16. "sign": getSign(key, clientId, timestamp),
  17. "apiCode": apiCode,
  18. "dataParams": data,
  19. }
  20. post, err := zhios_third_party_utils.CurlPost(url, zhios_third_party_utils.SerializeStr(param), nil)
  21. return string(post), err
  22. }
  23. func getSign(key, clientId, timestamp string) string {
  24. return strings.ToUpper(php2go.Md5("{\"clientId\":\"" + clientId + "\",\"privateKey\":\"" + key + "\",\"timestamp\":\"" + timestamp + "\"}"))
  25. }