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
507 B
21 lines
507 B
2 years ago
|
package wechatoffice
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"errors"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
func (c *Client) GetAccessTokenMonitor() (string, error) {
|
||
|
if c.config.RedisClient.Db == nil {
|
||
|
return "", errors.New("驱动没有初始化")
|
||
|
}
|
||
|
result := c.GetCallBackIp()
|
||
|
if len(result.Result.IpList) > 0 {
|
||
|
return c.config.AccessToken, nil
|
||
|
}
|
||
|
token := c.CgiBinToken()
|
||
|
c.config.RedisClient.Db.Set(context.Background(), c.getAccessTokenCacheKeyName(), token.Result.AccessToken, time.Second*7000)
|
||
|
return token.Result.AccessToken, nil
|
||
|
}
|