蛋蛋星球-制度模式
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 1.0 KiB

1 month ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package kuaizhan
  2. import (
  3. zhios_order_relate_utils "code.fnuoos.com/EggPlanet/egg_models.git/utils"
  4. "crypto/md5"
  5. "encoding/hex"
  6. "fmt"
  7. "github.com/syyongx/php2go"
  8. "sort"
  9. "strings"
  10. )
  11. func KuaizhanSend(appKey, appSecret, link string) (string, error) {
  12. url := "https://cloud.kuaizhan.com/api/v1/km/genShortLink"
  13. param := map[string]string{
  14. "appKey": appKey,
  15. "link": link,
  16. "format": "json",
  17. "expire": "2100-01-01",
  18. }
  19. keys := []string{}
  20. for k := range param {
  21. keys = append(keys, k)
  22. }
  23. // 排序asc
  24. sort.Strings(keys)
  25. str := ""
  26. for _, v := range keys {
  27. str += v + param[v]
  28. }
  29. hash := md5.Sum([]byte(appSecret + str + appSecret)) // 计算MD5值
  30. param["sign"] = hex.EncodeToString(hash[:]) // 转换为十六进制字符串
  31. for k, v := range param {
  32. if strings.Contains(url, "?") == false {
  33. url += "?" + k + "=" + php2go.URLEncode(v)
  34. } else {
  35. url += "&" + k + "=" + php2go.URLEncode(v)
  36. }
  37. }
  38. get, err := zhios_order_relate_utils.CurlGet(url, nil)
  39. fmt.Println(string(get))
  40. fmt.Println(err)
  41. return string(get), err
  42. }