From e6c88df690780d33f7e649f0190ed9c2412ccaa0 Mon Sep 17 00:00:00 2001 From: Clement Venard Date: Wed, 29 Nov 2017 16:06:52 +0800 Subject: [PATCH] removed url as a command line argument and added it as a constant as the API url is always the same --- main.go | 7 ------- plugin.go | 4 ++-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index 698e1b7..ec35b42 100644 --- a/main.go +++ b/main.go @@ -23,12 +23,6 @@ func main() { EnvVar: "PLUGIN_METHOD", Value: "POST", }, - cli.StringFlag{ - Name: "url", - Usage: "wechat work url", - EnvVar: "PLUGIN_URL", - Value: "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=", - }, cli.StringFlag{ Name: "corpid", Usage: "The corpid to get the access token", @@ -226,7 +220,6 @@ func run(c *cli.Context) error { CorpSecret: c.String("corp-secret"), Agentid: c.Int("agentid"), MsgType: c.String("msgtype"), - URL: c.String("url"), MsgURL: c.String("msgurl"), BtnTxt: c.String("btntxt"), ToUser: c.String("touser"), diff --git a/plugin.go b/plugin.go index 825d60c..bd8d649 100644 --- a/plugin.go +++ b/plugin.go @@ -89,8 +89,8 @@ func (p Plugin) Exec() error { var buf bytes.Buffer var b []byte - // GET request to get the access token - accessURL := p.Config.URL + p.Config.CorpID + "&corpsecret=" + p.Config.CorpSecret + // construct URL to get access token + accessURL := "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" + p.Config.CorpID + "&corpsecret=" + p.Config.CorpSecret fmt.Println("URL:>", accessURL) req, err := http.NewRequest("GET", accessURL, bytes.NewBuffer(b))