Merge pull request '🔥 移除短链接生成代码,疑似会引起封号' (#85) from hotfix into main
All checks were successful
BuildImage / build-image (push) Successful in 1m23s
All checks were successful
BuildImage / build-image (push) Successful in 1m23s
Reviewed-on: #85
This commit is contained in:
commit
5fac1b56f7
@ -4,7 +4,6 @@ package config
|
||||
type system struct {
|
||||
Domain string `json:"domain" yaml:"domain"` // 域名
|
||||
AlApiToken string `json:"alApiToken" yaml:"alApiToken"` // AL API Token
|
||||
UrlcApiToken string `json:"urlcApiToken" yaml:"urlcApiToken"` // urlc.cn API Token
|
||||
NewFriendNotify newFriendNotify `json:"newFriendNotify" yaml:"newFriendNotify"` // 新好友通知
|
||||
DefaultRule defaultRule `json:"defaultRule" yaml:"defaultRule"` // 默认规则
|
||||
}
|
||||
|
@ -75,10 +75,7 @@ func getTopData() (data []string) {
|
||||
}
|
||||
d.Channel = "百度"
|
||||
newDatas = append(newDatas, d)
|
||||
shortUrl := utils.GenShortUrl(d.Url)
|
||||
if shortUrl != "" {
|
||||
data = append(data, fmt.Sprintf("标题: %s\n热度: %s\n详情: %s", d.Title, d.Hot, shortUrl))
|
||||
}
|
||||
data = append(data, fmt.Sprintf("标题: %s\n热度: %s\n详情: %s", d.Title, d.Hot, d.Url))
|
||||
}
|
||||
// 保存新数据到数据库
|
||||
if len(newDatas) > 0 {
|
||||
|
@ -1,37 +0,0 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"go-wechat/config"
|
||||
"go-wechat/model/dto"
|
||||
"log"
|
||||
)
|
||||
|
||||
// GenShortUrl
|
||||
// @description: 生成短链接
|
||||
// @param url
|
||||
// @return shortUrl
|
||||
func GenShortUrl(url string) (shortUrl string) {
|
||||
// 组装参数
|
||||
param := map[string]any{
|
||||
"url": url,
|
||||
}
|
||||
pbs, _ := json.Marshal(param)
|
||||
|
||||
var respData dto.ShortUrlResponse
|
||||
res := resty.New()
|
||||
resp, err := res.R().
|
||||
SetHeader("Content-Type", "application/json;chartset=utf-8").
|
||||
SetAuthScheme("Token").
|
||||
SetAuthToken(config.Conf.System.UrlcApiToken).
|
||||
SetBody(string(pbs)).
|
||||
Post("https://www.urlc.cn/api/url/add")
|
||||
if err != nil {
|
||||
log.Printf("短链接获取失败: %s", err.Error())
|
||||
return
|
||||
}
|
||||
log.Printf("短链接获取结果: %s", resp.String())
|
||||
_ = json.Unmarshal(resp.Body(), &respData)
|
||||
return respData.Short
|
||||
}
|
Loading…
Reference in New Issue
Block a user