收藏
回答

请问小程序消息模板是不是还是需要后台服务器的支持?

 报错:“https://api.weixin.qq.com 不在以下 request 合法域名列表中,”

给出的解释是:“微信公众平台小程序后台的服务器地址设置也将禁止将“api.weixin.qq.com”域名的配置,所有对于“api.weixin.qq.com”域名下的接口请求请全部通过后台服务器发起,请勿直接通过小程序的前端代码发起。


是否意味着消息模板还是需要后台服务器的支持?既然小程序推出了云开发,目的是减少后台服务器的设置和维护,那这块建议也一并考虑

回答关注问题邀请回答
收藏

1 个回答

  • 半寸灰
    半寸灰
    2018-10-10

    可以是云函数  不过  acc token  有点麻烦  。因为没有定时函数

    2018-10-10
    有用
    回复 3
    • 2018-10-10

      谢谢,试了下云函数,没有报错,但始终返回null,求解

      {errMsg: "cloud.callFunction:ok", result: null, requestID: "3860b1e7-cc89-11e8-a0ac-525400e8849e"}


      控制台信息:

      • 返回结果:

        null


      • 日志:

        START RequestId: 3860b1e7-cc89-11e8-a0ac-525400e8849e

        Event RequestId: 3860b1e7-cc89-11e8-a0ac-525400e8849e Event:{"formId":"the formId is a mock one","userInfo":{"appId":"*****","openId":"*****"}}

        END RequestId: 3860b1e7-cc89-11e8-a0ac-525400e8849e

        Report RequestId: 3860b1e7-cc89-11e8-a0ac-525400e8849e Duration:184.506ms Memory:256MB MaxMemoryUsed:2.36719MB


      2018-10-10
      回复
    • 半寸灰
      半寸灰
      2018-10-11回复

      //npm install  request-promise

      const rp = require('request-promise');





      // 云函数入口函数

      exports.main = async(event, context) => {





      var res = await rp(

      {

      method: 'get',

      uri: 'https://xxxx.com',

      qs: { },//参数

      headers: {},//请求头

      json: true  //是否json数据

      }

      ).then((  body) => {


      return body


      }).catch(err => {

      return err;

      })



      return res;


      }


      2018-10-11
      回复
    • 2018-10-11回复半寸灰

      谢谢指导,果然ok,刚开始没有理解wx.request与request-promise的区别,走了些弯路

      ps:我用的是post方式,把qs改成了body


      2018-10-11
      回复
登录 后发表内容