간단히하기 위해 json을 배열로 변형 할 수 있습니다.
$jsonPHP = json_decode($request,true);
이제 간략하게 살펴 보겠습니다. 문서 (http://openweathermap.org/current),
참고 또한 에 따르면 나는 전에이 API를 사용한 적이 없으니까. 나는 여기서 도우려고하고있다. 당신이 api.openweathermap.org/data/2.5/weather?lat=35&lon=139
에 충돌하는 경우
{"coord":{"lon":139,"lat":35},
"sys":{"country":"JP","sunrise":1369769524,"sunset":1369821049},
"weather":[{"id":804,"main":"clouds","description":"overcast clouds","icon":"04n"}],
"main":{"temp":289.5,"humidity":89,"pressure":1013,"temp_min":287.04,"temp_max":292.04},
"wind":{"speed":7.31,"deg":187.002},
"rain":{"3h":0},
"clouds":{"all":92},
"dt":1369824698,
"id":1851632,
"name":"Shuzenji",
"cod":200}
는 이제 날씨를 및 습도을 원하는 가정
로
그것은 응답, 그것은 단지 :
날씨 :
echo $jsonPHP["weather"][0]["id"];
습도 : 당신이 경우에 대한
{"cod":401, "message": "Invalid API key. Please see http://openweathermap.org/faq#error401 for more info."}
로
http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139 및 얻을 응답을 치면
echo $jsonPHP["main"]["humidity"];
참고도 즉, 그들은 여기에서 설명했습니다
http://openweathermap.org/faq#error401 즉 :
Q: API calls return an error 401
A: Starting from 9 October 2015 our API requires a valid APPID for access. Note that this does not mean that our API is subscription-only now - please take a minute to register a free account to receive a key.
We are sorry for inconvenience but this is a necessary measure that will help us deliver our services to you faster and more reliably.
For FOSS developers: we welcome free and open source software and are willing to help you. If you want to use OWM data in your free software application please register an API key and file a ticket describing your application and API key registered. OWM will review your request lift access limits for your key if used in open source application.
문서가 귀하에게 중요하지 않았습니까? –
오픈 소스 라이센스로 날씨가 공개 되었습니까? 그것은 좋은 소식입니다! – arkascha
일종의, couldnt는 100 % 정확한 답변을 찾았습니다. 나는 그걸 들여다 보았으나 내가 한 모든 시도는 실패했다. –