From 14dbd9d2bdb84c4be5a7011da0b3104308b1eb2e Mon Sep 17 00:00:00 2001 From: Patrick Peng Sun Date: Wed, 26 Apr 2017 14:10:24 +1000 Subject: [PATCH] move public account id to config --- common_test.go | 4 +++- config.go | 3 +++ outMsg.go | 5 +---- server_config.json | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/common_test.go b/common_test.go index b48ea27..bc2c726 100644 --- a/common_test.go +++ b/common_test.go @@ -12,7 +12,9 @@ func SetupConfig() { "cmtWK2teRnLOXyO5dw7lJkETv9jCeNAqYyguEu5D8gG", "wx876e233fde456b7b", "4a91aa328569b10a9fb97adeb8b0af58", - "wechat_hitxy_access_token"} + "wechat_hitxy_access_token", + "gh_f09231355c68"} + } func AssertEqual(t *testing.T, a interface{}, b interface{}, message string) { diff --git a/config.go b/config.go index c5114ba..f9bb602 100644 --- a/config.go +++ b/config.go @@ -24,6 +24,9 @@ type WechatAPIConfig struct { //AuthTokenSaveTo AuthTokenSaveTo string `json:"AuthTokenSaveTo"` + + //PublicAccountID + PublicAccountID string `json:"PublicAccountID"` } //APIConfig contains secrets that cannot store in source file diff --git a/outMsg.go b/outMsg.go index 2429e63..8627c2e 100644 --- a/outMsg.go +++ b/outMsg.go @@ -19,12 +19,9 @@ func BuildTextMsg(txt string, ToUserName string) (string, error) { ` - msg := fmt.Sprintf(template, ToUserName, "gh_f09231355c68", int32(time.Now().Unix()), txt) - fmt.Println(msg) + msg := fmt.Sprintf(template, ToUserName, APIConfig.PublicAccountID, int32(time.Now().Unix()), txt) e := Encode(msg) - str, _, _, _ := signMsg(e) - fmt.Println(str) return str, nil } diff --git a/server_config.json b/server_config.json index 747077c..0fea69c 100644 --- a/server_config.json +++ b/server_config.json @@ -3,5 +3,6 @@ "EncodingAESKey": "cmtWK2teRnLOXyO5dw7lJkETv9jCeNAqYyguEu5D8gG", "Appid": "wx876e233fde456b7b", "AppSecret": "4a91aa328569b10a9fb97adeb8b0af58", - "AuthTokenSaveTo": "/tmp/wechat_hitxy_token" + "AuthTokenSaveTo": "/tmp/wechat_hitxy_token", + "PublicAccountID":"gh_f09231355c68" } \ No newline at end of file