蛋蛋星球-制度模式
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

45 行
1.0 KiB

  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. }