微信小程序获取用户IP地址,HTTPS接口

很简单实用的ip地址接口, 只返回当前ip

接口返回内容格式为:
{“ip”:“27.211.239.98”}

// 获取IP地址
wx.request({
  url: 'https://tianqiapi.com/ip/',
  data: {
  },
  method: 'POST',
  header: {
    'content-type': 'application/x-www-form-urlencoded'
  },
  success: function (res) {
    console.log('IP地址: ' + res.data.ip);
  }
});

温馨提醒
如果是测试, 请勾选配置 不校验合法域名、web-view(业务域名)、TLS 版本以及 HTTPS 证书
如果正式使用, 请添加安全域名 ( tianqiapi.com )

发布了44 篇原创文章 · 获赞 22 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/qq_38832501/article/details/92074616