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.
|
|
|
package wechatoffice
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (app *App) GetAccessTokenMonitor() (string, error) {
|
|
|
|
if app.Redis.Db == nil {
|
|
|
|
return "", errors.New("驱动没有初始化")
|
|
|
|
}
|
|
|
|
result := app.GetCallBackIp()
|
|
|
|
if len(result.Result.IpList) > 0 {
|
|
|
|
return app.AccessToken, nil
|
|
|
|
}
|
|
|
|
token := app.CgiBinToken()
|
|
|
|
app.Redis.Db.Set(context.Background(), app.getAccessTokenCacheKeyName(), token.Result.AccessToken, time.Second*7000)
|
|
|
|
return token.Result.AccessToken, nil
|
|
|
|
}
|