0
간단한 웹 API를 사용하여 도시 날씨 정보를 얻고 있습니다 런던. 그러나 필요한 응답을 얻지 못하고 대신 401 오류. 내가 뭐 잘못하고 있니? 다음 API를날씨 API (RESTful) 제공 오류
http://openweathermap.org/current
ERROR를 사용
HTML
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('button').click(function(){
$.ajax({
type: "get",
url: "http://api.openweathermap.org/data/2.5/weather?q=London",
dataType: "json",
contentType: 'application/json',
success: function(data) {
//What to do on success
}
});
});
});
</script>
</head>
<body>
<button>Click Me</button>
</body>
</html>
해당 호출 : '{ "cod": 401 "message": "유효하지 않은 API 키 .http : // o를 참조하십시오. 자세한 정보는 penweathermap.org/faq#error401을 참조하십시오. "}'요청에 유효한 API 키를 전달하고 있습니까? http://openweathermap.org/faq#error401 –
Pls는 첨부 된 페이지 및 문서를 참조하십시오. 나는 그곳으로부터 URL을 골랐다. – Deadpool
설명서에 사용하려면 API 키가 있어야한다고 나와 있습니다 (http://openweathermap.org/appid). 또한 무료 계정에서는 API 호출 횟수에 따라 요금이 제한된다는 점에 유의하십시오. 귀하의 웹 사이트에이 서비스를 의뢰해야한다면 SLA에 대한 지불을 제안합니다 –