提示:​https://api.weixin.qq.com不在以下合法域名列表中
发布于 6 年前 作者 licheng 13098 次浏览 来自 问答

如图:

https://api.weixin.qq.com 这个域名不是腾讯的吗,还需要配置在微信小程序后台?

3 回复

能提供一个例子吗

在服务器完成。

我现在是想通过该接口来获取openid,如果这样不允许的话,我该如何获取openid:

 getopenid:function(){ //获取openid

   var that = this;

   wx.login({

     success: function (res) {

       var d = that.globalData;//这里存储了appid、secret、token串    

       var url = ‘https://api.weixin.qq.com/sns/jscode2session?appid=’ + d.appid + ‘&secret=’ + d.secret + ‘&js_code=’ + res.code + ‘&grant_type=authorization_code’;

       wx.request({

         url: url,

         method: ‘GET’,

         success: function (res) {

          that.globalData.openid = res.data.openid;

         }

       });//对应wx.request

 

     } //对应success

   }); //对应wx.login

 },

回到顶部