|
@@ -4,6 +4,7 @@ import ( |
|
|
"applet/app/db" |
|
|
"applet/app/db" |
|
|
offical "applet/app/db/official" |
|
|
offical "applet/app/db/official" |
|
|
"applet/app/utils" |
|
|
"applet/app/utils" |
|
|
|
|
|
"applet/app/utils/cache" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/kuaishou" |
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/kuaishou" |
|
|
"github.com/tidwall/gjson" |
|
|
"github.com/tidwall/gjson" |
|
|
"strings" |
|
|
"strings" |
|
@@ -13,13 +14,13 @@ import ( |
|
|
func KuaishouAuth() { |
|
|
func KuaishouAuth() { |
|
|
kuaishouAppkey := offical.MasterListCfgGetOneData("0", "kuaishou_kfx_appkey") |
|
|
kuaishouAppkey := offical.MasterListCfgGetOneData("0", "kuaishou_kfx_appkey") |
|
|
kuaishouAppSecret := offical.MasterListCfgGetOneData("0", "kuaishou_kfx_app_secret") |
|
|
kuaishouAppSecret := offical.MasterListCfgGetOneData("0", "kuaishou_kfx_app_secret") |
|
|
kuaishou_official_expires_in := db.MasterListCfgGetOneData("0", "kuaishou_official_expires_in") |
|
|
|
|
|
kuaishou_official_refresh_token := db.MasterListCfgGetOneData("0", "kuaishou_official_refresh_token") |
|
|
|
|
|
if utils.StrToInt64(kuaishou_official_expires_in) < time.Now().Unix() { |
|
|
|
|
|
|
|
|
kuaishouOfficialExpiresIn := db.MasterListCfgGetOneData("0", "kuaishou_official_expires_in") |
|
|
|
|
|
kuaishouOfficialRefreshToken := db.MasterListCfgGetOneData("0", "kuaishou_official_refresh_token") |
|
|
|
|
|
if utils.StrToInt64(kuaishouOfficialExpiresIn) < time.Now().Unix() { |
|
|
args := map[string]string{ |
|
|
args := map[string]string{ |
|
|
"app_id": kuaishouAppkey, |
|
|
"app_id": kuaishouAppkey, |
|
|
"grant_type": "refresh_token", |
|
|
"grant_type": "refresh_token", |
|
|
"refresh_token": kuaishou_official_refresh_token, |
|
|
|
|
|
|
|
|
"refresh_token": kuaishouOfficialRefreshToken, |
|
|
"app_secret": kuaishouAppSecret, |
|
|
"app_secret": kuaishouAppSecret, |
|
|
} |
|
|
} |
|
|
token, _ := kuaishou.GetKuaishouRefreshToken(args) |
|
|
token, _ := kuaishou.GetKuaishouRefreshToken(args) |
|
@@ -32,6 +33,7 @@ func KuaishouAuth() { |
|
|
} |
|
|
} |
|
|
teamAccessRefreshToken := gjson.Get(token, "refresh_token").String() |
|
|
teamAccessRefreshToken := gjson.Get(token, "refresh_token").String() |
|
|
teamAccessTime := time.Now().Unix() + gjson.Get(token, "expires_in").Int() - 60 |
|
|
teamAccessTime := time.Now().Unix() + gjson.Get(token, "expires_in").Int() - 60 |
|
|
|
|
|
cache.SetEx("kuaishou:"+kuaishouAppkey, accessToken, int(gjson.Get(token, "expires_in").Int()-60)) |
|
|
db.MasterListCfgSave("0", "kuaishou_official_access_token", accessToken) |
|
|
db.MasterListCfgSave("0", "kuaishou_official_access_token", accessToken) |
|
|
db.MasterListCfgSave("0", "kuaishou_official_expires_in", utils.Int64ToStr(teamAccessTime)) |
|
|
db.MasterListCfgSave("0", "kuaishou_official_expires_in", utils.Int64ToStr(teamAccessTime)) |
|
|
db.MasterListCfgSave("0", "kuaishou_official_refresh_token", teamAccessRefreshToken) |
|
|
db.MasterListCfgSave("0", "kuaishou_official_refresh_token", teamAccessRefreshToken) |
|
|