本專案旨在為多個微信公眾號提供中控服務, 包含以下服務內容:
- 校驗後臺簽名配置
- 處理微信公眾號訊息
- 獲取access_token
- 獲取jssdk簽名
- 自定義選單
本專案採用的技術選型為:
- 開發語言 nodejs
- 開發框架 eggjs
- 記憶體資料庫 redis
本篇文章主要從以下4個方面來實現這個中控服務:
- eggjs外掛和配置
- 定時任務獲取token等資訊
- 路由定義和controller層接收並處理引數
- service層實現
以下為具體的實現步驟:
一、eggjs外掛和配置
新增egg-redis和xml2js依賴庫, 並開啟egg-redis外掛


配置解析微信公眾號傳遞的xml資料

配置redis

配置多個微信公眾號的選單, appId, appSecret 以及 redis中accessToken和jssdk的key

二、定時任務獲取token等資訊

三、路由定義和controller層接收並處理引數
路由定義

controller層接收並處理引數

四、service層實現



extend/help.js檔案內容如下:
