天气地下API天文学 [英] Weather Underground API Astronomy
问题描述
我正在使用Weather Underground API,解析Json,并得到结果. 由于某种原因,这种方法无法获得正确的天文学结果,例如:
I am using the Weather Underground API, parsing Json, and getting a result. For some reason this is not working to get the right astronomy results like so:
http://www.wunderground. com/weather/api/d/docs?d = data/astronomy& MR = 1
月亮:
当前:
日出:
日落:
这是我目前为止没有得到任何结果:(更新)
Here is what I have so far and am getting no results:(updated)
$.ajax({
url: "http://api.wunderground.com/api/72df18b7f213607b/astronomy/q/CO/Alamosa.json",
dataType : "jsonp",
success : function(parsed_json) {
var hourly = parsed_json['moon_phase']['current_time']['sunrise']['sunset'];
for (index in hourly) {
var newHourlyString = moon_phase[index]['hour'] + ' is ' + current_time[index]['hour'];
var newHourlyParagraph = $('<p/>').text(newHourlyString);
$(".astro").append(newHourlyParagraph);
}
}
});
推荐答案
尝试一下.您的问题遗漏了很多东西,但是我能够从您链接的视频中提取信息.
Try this out. There was a lot missing from your question but I was able to pull info from the video you linked.
您还应该研究提出更好的问题,其中包括所有必要的详细信息,以获得更好的答案.
You should also work on asking better questions with all necessary details included to get better answers.
$(document).ready(function() {
$.ajax({
url: "http://api.wunderground.com/api/72df18b7f213607b/astronomy/q/CO/Alamosa.json",
dataType: "jsonp",
success: function(parsed_json) {
var moon_phase = parsed_json['moon_phase'];
var moonData = {};
moonData['Moon Ill'] = moon_phase['percentIlluminated'] + '%',
moonData['Moon Age'] = moon_phase['ageOfMoon'],
moonData['Current Time'] = moon_phase['current_time']['hour'] + ":" + moon_phase['current_time']['minute'],
moonData['Sunrise'] = moon_phase['sunrise']['hour'] + ":" + moon_phase['sunrise']['minute'],
moonData['Sunset'] = moon_phase['sunset']['hour'] + ":" + moon_phase['sunset']['minute'];
for (index in moonData) {
if (moonData.hasOwnProperty(index)) {
var newHourlyString = index + ': ' + moonData[index];
var newHourlyParagraph = $('<p/>').text(newHourlyString);
$(".astro").append(newHourlyParagraph);
}
}
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="astro"></div>
这篇关于天气地下API天文学的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!