微信小程序获取国外今日天气预报信息接口
时间:2019-04-26 21:07:03
收藏:0
阅读:285
使用天气API的国外今日天气预报接口制作
返回json预览
{
cityid: "601010100",
city: "堪培拉",
cityEn: "Canberra",
country: "澳大利亚",
countryEn: "Australia",
update_time: "2019-04-24 18:00:00",
wea: "晴",
wea_img: "qing",
tem: "22",
win: "西北风",
win_speed: "<3级"
}
小程序获取天气的JS
// 天气api国外今日天气获取, 根据城市编号
weathertoday:function(ip){
var _this = this;
wx.request({
url: ‘https://www.tianqiapi.com/api/?version=v51&appid=1001&appsecret=1002&cityid=601010100‘,
data: {
‘ip‘: ip
},
method: ‘GET‘,
header: {
‘content-type‘: ‘application/x-www-form-urlencoded‘
},
success: function (res) {
_this.setData({
weather: res.data
});
console.log(_this.data.weather)
}
});
},
有问题可以联系QQ 445899710 免费协助解决
天气API官网 https://www.tianqiapi.com/
评论(0)