MCPcopy
hub / github.com/silenceper/wechat / GetAgentConfig

Method GetAgentConfig

work/jsapi/jsapi.go:58–75  ·  view source on GitHub ↗

GetAgentConfig 获取企业微信应用JS配置 https://developer.work.weixin.qq.com/document/path/94313

(uri string)

Source from the content-addressed store, hash-verified

56
57// GetAgentConfig 获取企业微信应用JS配置 https://developer.work.weixin.qq.com/document/path/94313
58func (js *Js) GetAgentConfig(uri string) (config *Config, err error) {
59 config = new(Config)
60 var accessToken string
61 accessToken, err = js.GetAccessToken()
62 if err != nil {
63 return
64 }
65 var ticketStr string
66 ticketStr, err = js.jsTicket.GetTicket(accessToken, credential.TicketTypeAgentJs)
67 if err != nil {
68 return
69 }
70 config.NonceStr = util.RandomStr(16)
71 config.Timestamp = util.GetCurrTS()
72 str := fmt.Sprintf("jsapi_ticket=%s&noncestr=%s&timestamp=%d&url=%s", ticketStr, config.NonceStr, config.Timestamp, uri)
73 config.Signature = util.Signature(str)
74 return
75}

Callers

nothing calls this directly

Calls 5

RandomStrFunction · 0.92
GetCurrTSFunction · 0.92
SignatureFunction · 0.92
GetAccessTokenMethod · 0.65
GetTicketMethod · 0.65

Tested by

no test coverage detected