Browse Source

快站

master
huangjiajun 3 months ago
parent
commit
74e7e23bee
3 changed files with 85 additions and 8 deletions
  1. +44
    -3
      kuaizhan/short_url.go
  2. +4
    -4
      kuaizhan/url.go
  3. +37
    -1
      qianzhu/api.go

+ 44
- 3
kuaizhan/short_url.go View File

@@ -6,21 +6,62 @@ import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db/offical/model"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"fmt"
"github.com/tidwall/gjson"
"strings"
"time"
"xorm.io/xorm"
)

func ShortUrlSend(engine *xorm.Engine, uid string, url string) string {
num := KuaizhanShortUrlNumGetSmsNum(engine, uid)
func ShortUrlSend(engine *xorm.Engine, mid string, url string) string {
num := KuaizhanShortUrlNumGetSmsNum(engine, mid)
if num <= 0 {
return url
}
shortUrl := ""
if strings.Contains(url, "kuaizhan") {

shortUrl = ""
}
if shortUrl == "" {
shortUrl = GetBaiduUrl(url)
if shortUrl != "" {
args := map[string]interface{}{
"uid": mid,
}
KuaizhanShortUrlSend(engine, args)
url = shortUrl
}
}
return url
}

func GetBaiduUrl(url string) string {
method := "https://dwz.cn/admin/v2/create"
arg := map[string]string{
"TermOfValidity": "1-year", // "long-term":永久,默认值 "1-year":1年
"Url": url,
}
headers := map[string]string{
"Token": "eecdf4b18f416b0cf26fef98f7e1f4ff",
}
post, err := zhios_third_party_utils.CurlPost(method, zhios_third_party_utils.SerializeStr(arg), headers)
fmt.Println(string(post))
fmt.Println(err)
return gjson.Get(string(post), "ShortUrl").String()
}
func GetThreePartUrl(url string) {
method := "https://cloud.kuaizhan.com/api/v1/tbk/genShortUrl"
appKey := "7w2N8ohpFJxW"
appSecret := "11f7fa9a66c75229aca909b6c171cf84fa747ec4"
arg := map[string]string{
"appKey": appKey,
"url": url,
}
str := "appKey" + appKey + "url" + url
arg["sign"] = zhios_third_party_utils.Md5(appSecret + str + appSecret)
post, err := zhios_third_party_utils.CurlPost(method, arg, nil)
fmt.Println(string(post))
fmt.Println(err)
}
func GetKuaizhanUrl(url string) {
method := "https://cloud.kuaizhan.com/api/v1/tbk/genKzShortUrl"
appKey := "7w2N8ohpFJxW"


+ 4
- 4
kuaizhan/url.go View File

@@ -8,14 +8,14 @@ import (
)

func KuaizhanUrl(engine *xorm.Engine, args map[string]string) string {
kuaizhan_host := offical.SysCfgByKeyStr(engine, "kuaizhan_host")
if kuaizhan_host == "" {
kuaizhanHost := offical.SysCfgByKeyStr(engine, "kuaizhan_host")
if kuaizhanHost == "" {
return ""
}
numData := offical.GetKuaizhanUrl(engine, args["mid"])
if numData.EndTime.Unix() <= time.Now().Unix() {
return ""
}
kuaizhan_host += "?code=" + php2go.URLEncode(php2go.Base64Encode(args["url"]))
return kuaizhan_host
kuaizhanHost += "?code=" + php2go.URLEncode(php2go.Base64Encode(args["url"]))
return kuaizhanHost
}

+ 37
- 1
qianzhu/api.go View File

@@ -1,5 +1,41 @@
package qianzhu

func GetKfcUrl(key, secret string, param map[string]string) {
import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/comm"
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"fmt"
"github.com/tidwall/gjson"
"strings"
"time"
)

var apiUrl = "https://live.qianzhu8.com/api/v2/platform/getToken"
var url = "https://m.qianzhu8.com"

func GetUrl(method, key, secret string, param map[string]string) string {
str := ""
param["timestamp"] = zhios_third_party_utils.Int64ToStr(time.Now().Unix())
param["platformId"] = key
strMap := comm.KsortToStr(param)
for _, v := range strMap {
if str == "" {
str += v + "=" + param[v]
} else {
str += "&" + v + "=" + param[v]
}
}
str += secret
param["sign"] = zhios_third_party_utils.Md5(str)
for k, v := range param {
if strings.Contains(apiUrl, "?") == false {
apiUrl += "?" + k + "=" + v
} else {
apiUrl += "&" + k + "=" + v
}
}
get, _ := zhios_third_party_utils.CurlGet(apiUrl, nil)
token := gjson.Get(string(get), "data.accessToken").String()
url += method + "?token=" + token + "&platformId=" + param["platformId"] + "&platformUniqueId=" + param["platformUniqueId"] + "&subPlatformId=" + param["subPlatformId"]
fmt.Println(url)
return url
}

Loading…
Cancel
Save