微信小程序獲取用戶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 )

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章