|
@@ -49,7 +49,13 @@ type OfficialAccount struct {
|
|
|
|
|
|
|
|
// NewOfficialAccount 实例化公众号API
|
|
// NewOfficialAccount 实例化公众号API
|
|
|
func NewOfficialAccount(cfg *config.Config) *OfficialAccount {
|
|
func NewOfficialAccount(cfg *config.Config) *OfficialAccount {
|
|
|
- defaultAkHandle := credential.NewDefaultAccessToken(cfg.AppID, cfg.AppSecret, credential.CacheKeyOfficialAccountPrefix, cfg.Cache)
|
|
|
|
|
|
|
+ var defaultAkHandle credential.AccessTokenContextHandle
|
|
|
|
|
+ const cacheKeyPrefix = credential.CacheKeyOfficialAccountPrefix
|
|
|
|
|
+ if cfg.UseStableAK {
|
|
|
|
|
+ defaultAkHandle = credential.NewStableAccessToken(cfg.AppID, cfg.AppSecret, cacheKeyPrefix, cfg.Cache)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ defaultAkHandle = credential.NewDefaultAccessToken(cfg.AppID, cfg.AppSecret, cacheKeyPrefix, cfg.Cache)
|
|
|
|
|
+ }
|
|
|
ctx := &context.Context{
|
|
ctx := &context.Context{
|
|
|
Config: cfg,
|
|
Config: cfg,
|
|
|
AccessTokenHandle: defaultAkHandle,
|
|
AccessTokenHandle: defaultAkHandle,
|