|
- package main
-
- import (
- "encoding/json"
- "io/ioutil"
- "log"
- )
-
- //WechatAPIConfig all secret related API Config
- type WechatAPIConfig struct {
- //Token is the wechat API shared secrete
- Token string `json:"Token"`
-
- //EncodingAESKey is the Key for encrypt messages
- EncodingAESKey string `'json:"EncodingAESKey"`
-
- //Appid is wechat public account appid
- Appid string `json:"Appid"`
-
- //AppSecret is how we identify ourselves.
- AppSecret string `json:"AppSecret"`
- }
-
- //APIConfig contains secrets that cannot store in source file
- var APIConfig WechatAPIConfig
-
- func readConfig() error {
-
- log.Printf("read config from %s\r\n", "server_config.json")
- body, err := ioutil.ReadFile("server_config.json")
- if err != nil {
- return err
- }
- return json.Unmarshal(body, &APIConfig)
- }
|