|
1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- package kuaizhan
-
- import (
- zhios_order_relate_utils "code.fnuoos.com/EggPlanet/egg_models.git/utils"
- "crypto/md5"
- "encoding/hex"
- "fmt"
- "github.com/syyongx/php2go"
- "sort"
- "strings"
- )
-
- func KuaizhanSend(appKey, appSecret, link string) (string, error) {
- url := "https://cloud.kuaizhan.com/api/v1/km/genShortLink"
- param := map[string]string{
- "appKey": appKey,
- "link": link,
- "format": "json",
- "expire": "2100-01-01",
- }
- keys := []string{}
- for k := range param {
- keys = append(keys, k)
- }
- // 排序asc
- sort.Strings(keys)
- str := ""
- for _, v := range keys {
- str += v + param[v]
- }
- hash := md5.Sum([]byte(appSecret + str + appSecret)) // 计算MD5值
- param["sign"] = hex.EncodeToString(hash[:]) // 转换为十六进制字符串
- for k, v := range param {
- if strings.Contains(url, "?") == false {
- url += "?" + k + "=" + php2go.URLEncode(v)
- } else {
- url += "&" + k + "=" + php2go.URLEncode(v)
- }
- }
- get, err := zhios_order_relate_utils.CurlGet(url, nil)
- fmt.Println(string(get))
- fmt.Println(err)
- return string(get), err
- }
|