<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 基礎配置 ## 服務端安裝think-weichat中間件 [https://github.com/akira-cn/think-wechat](https://github.com/akira-cn/think-wechat) ~~~ $ npm install think-wechat ~~~ ## 配置 middleware * 編輯 config/middleware.js ~~~js const path = require('path'); const wechat = require('think-wechat') const isDev = think.env === 'development'; module.exports = [ { handle: wechat, match: '/home/weixin', options: { token: 'weixin', appid: 'wxf23493b0cf5d0804', //encodingAESKey: '', //測試號不需要配置 checkSignature: true, // 可選,默認為true。由于微信公眾平臺接口調試工具在明文模式下不發送簽名,所以如要使用該測試工具,請將其設置為false }, }, { handle: 'payload', options: { uploadDir: path.join(think.ROOT_PATH, 'runtime/data'), }, }, ]; ~~~ **注意**:think-wechat 必須要在 payload 中間件前面加載,它會代替 payload 處理微信發過來的 post 請求中的數據。 * 根據 match 配置,增加對應的 controller 和 action ## 登陸微信官方開發者中心,配置接口信息 請填寫接口配置信息,此信息需要你有自己的服務器資源,填寫的URL需要正確響應微信發送的Token驗證,請閱讀[消息接口使用指南](http://mp.weixin.qq.com/wiki/index.php?title=%E6%B6%88%E6%81%AF%E6%8E%A5%E5%8F%A3%E6%8C%87%E5%8D%97)。 URL:[http://zengqingsong.oicp.net/home/weixin](http://zengqingsong.oicp.net/home/weixin) Token:weixin > 本地開發,可以使用花生殼做本地域名映射(微信公眾號開發必須80端口,所以需要有公網的服務器,本地開發使用花生殼做代理) 支持的 action 包括:textAction、imageAction、voiceAction、videoAction、shortvideoAction、locationAction、linkAction、eventAction、deviceTextAction、deviceEventAction。 ## DEMO 增加控制器home/controller/weixin ``` const DEFULT_AUTO_REPLY = '功能正在開發中~'; const BaseController = require('./base.js'); module.exports = class extends BaseController { constructor(ctx) { super(ctx); } //支持的 action // 包括:textAction、imageAction、voiceAction、videoAction、shortvideoAction、locationAction、linkAction、eventAction、deviceTextAction、deviceEventAction。 // https://github.com/akira-cn/think-wechat https://github.com/node-webot/wechat //微信公眾號控制器 /** * index action * @return {Promise} [] */ indexAction() { ///home/weixin/index?signature=6a8f855d69d080052142b85da4faafe149168a1d&echostr=7148202192707206511&timestamp=1558920224&nonce=418613906 // 驗證開發者服務器 // 這里只是演示,所以沒做簽名校驗,實際上應該要根據微信要求進行簽名校驗 const echostr = this.get('echostr'); return echostr; } textAction() { //發送文本消息 const {Content} = this.post(); //this.success('你發送給我的是:' + Content.trim()); this.success([ { title: '你來我家接我吧', description: '這是女神與高富帥之間的對話', picurl: 'http://nodeapi.cloudfoundry.com/qrcode.jpg', url: 'http://nodeapi.cloudfoundry.com/', }, ]); } eventAction() { const message = this.post(); this.success(JSON.stringify(message)); } __call() { this.success(DEFULT_AUTO_REPLY); } }; ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看