蛋蛋星球-制度模式
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 1 nedēļas
12345678910111213141516171819202122232425262728293031323334353637
  1. package baidu
  2. import (
  3. utils "code.fnuoos.com/EggPlanet/egg_system_rules.git/utils"
  4. "encoding/json"
  5. "fmt"
  6. )
  7. func BaiduShortenUrl(token, url string) (string, error) {
  8. host := "https://dwz.cn/admin/v2/create"
  9. args := map[string]string{
  10. "Url": url,
  11. "TermOfValidity": "1-year",
  12. }
  13. resp, err := utils.CurlPost(host, utils.Serialize(args), map[string]string{
  14. "Content-Type": "application/json",
  15. "Token": token,
  16. })
  17. // {"Code":0,"IsNew":true,"ShortUrl":"https://dwz.cn/4kSgiKVl","LongUrl":"https://open.taobao.com/search.htm?q=taobao.tbk.sc.material","ErrMsg":""}
  18. if err != nil {
  19. return "", err
  20. }
  21. var tmp struct {
  22. Code int `json:"Code"`
  23. IsNew bool `json:"IsNew"`
  24. ShortURL string `json:"ShortUrl"`
  25. LongURL string `json:"LongUrl"`
  26. ErrMsg string `json:"ErrMsg"`
  27. }
  28. fmt.Println("======分享==========", string(resp))
  29. if err = json.Unmarshal(resp, &tmp); err != nil {
  30. return "", err
  31. }
  32. return tmp.ShortURL, nil
  33. }