You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
485 B
21 lines
485 B
3 years ago
|
package wechatoffice
|
||
|
|
||
|
import (
|
||
2 years ago
|
"context"
|
||
3 years ago
|
"errors"
|
||
2 years ago
|
"time"
|
||
3 years ago
|
)
|
||
|
|
||
2 years ago
|
func (app *App) GetAccessTokenMonitor() (string, error) {
|
||
2 years ago
|
if app.redis.Db == nil {
|
||
2 years ago
|
return "", errors.New("驱动没有初始化")
|
||
|
}
|
||
|
result := app.GetCallBackIp()
|
||
|
if len(result.Result.IpList) > 0 {
|
||
2 years ago
|
return app.accessToken, nil
|
||
3 years ago
|
}
|
||
2 years ago
|
token := app.CgiBinToken()
|
||
2 years ago
|
app.redis.Db.Set(context.Background(), app.getAccessTokenCacheKeyName(), token.Result.AccessToken, time.Second*7000)
|
||
2 years ago
|
return token.Result.AccessToken, nil
|
||
3 years ago
|
}
|