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"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetJsapiTicketMonitor 监控api_ticket
|
|
|
|
func (app *App) GetJsapiTicketMonitor() (string, error) {
|
|
|
|
if app.redis.Db == nil {
|
|
|
|
return "", errors.New("驱动没有初始化")
|
|
|
|
}
|
|
|
|
result := app.DebugCgiBinTicketCheck()
|
|
|
|
if result.Result.Errcode == 0 {
|
|
|
|
return app.jsapiTicket, nil
|
|
|
|
}
|
|
|
|
app.accessToken = app.GetAccessToken()
|
|
|
|
token := app.CgiBinTicketGetTicket("jsapi")
|
|
|
|
app.redis.Db.Set(context.Background(), app.getJsapiTicketCacheKeyName(), token.Result.Ticket, time.Second*7000)
|
|
|
|
return token.Result.Ticket, nil
|
|
|
|
}
|