Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Usage:
初始化OpenWork对象,用于获取PermenanetCode和调用第三方API
`
import (
"github.com/ArtisanCloud/PowerWeChat/v3/src/work"
"github.com/ArtisanCloud/PowerWeChat/v3/src/openWork"
)
func OpenWork() (*openWork.OpenWork, error) {
cfg := Config().OpenWork
userConfig := openWork.UserConfig{
AppID: cfg.AppID,
Secret: cfg.Secret,
Token: cfg.Token,
AESKey: cfg.AESKey,
ProviderCorpID: cfg.ProviderCorpID,
ProviderSecret: cfg.ProviderSecret,
Cache: OpenWorkCache(),
Http: openWork.Http{
ProxyURI: cfg.ProxyURL,
},
Log: openWork.Log{
Driver: openWorkLogger,
Level: "debug",
},
HttpDebug: Config().Debug,
Debug: Config().Debug,
}
return openWork.NewOpenWork(&userConfig)
}
`
服务商应用获取PermanentCode后调用企业微信API
func (uc Usecase) OpenWorkClient(ctx context.Context, corp *pb.Corp) (*work.Work, error) { cfg := service.Config() userConfig := work.UserConfig{ CorpID: corp.GetOpenCorpId(), Secret: corp.GetAgent().GetSecret(), PermanentCode: corp.GetPermanentCode(), OpenWork: openWorkClt, AgentID: int(corp.GetOpenAgentId()), Token: cfg.OpenWork.Token, AESKey: cfg.OpenWork.AESKey, Cache: service.OpenWorkCache(), Http: work.Http{ ProxyURI: cfg.OpenWork.ProxyURL, }, OAuth: work.OAuth{ Callback: callbackURL, }, Log: work.Log{ Driver: openWorkClt.Logger.Driver, Level: "debug", }, HttpDebug: cfg.Debug, Debug: cfg.Debug, } return work.NewWork(&userConfig) }
第三方应用获取PermanentCode后调用企业微信API
func (uc Usecase) ProviderWorkClient(ctx context.Context, corp *pb.Corp) (*work.Work, error) { cfg := service.Config() userConfig := work.UserConfig{ CorpID: corp.GetOpenCorpId(), Secret: corp.GetPermanentCode(), Token: corp.GetAgent().GetToken(), AESKey: corp.GetAgent().GetAesKey(), Cache: service.OpenWorkCache(), Http: work.Http{ ProxyURI: cfg.OpenWork.ProxyURL, }, OAuth: work.OAuth{ Callback: callbackURL, }, Log: work.Log{ Driver: service.OpenWork().Logger.Driver, Level: "debug", }, HttpDebug: cfg.Debug, Debug: cfg.Debug, } return work.NewWork(&userConfig) }