manisha manisha - 3 months ago 15
Android Question

getting link of an API : openweathermap.com

I am a beginner, just made few simple apps in android sdk.
I learnt about extracting data of websites which have JSON format. i tried to extract data of "openweathermap.com" for the city London by API calls in execute method of AsynkTask, and my app got crashed by getting null result from web.

Though it is giving desired result when i am passing other links like http://openweathermap.org/current to get full web Contents.

here is my code, its working.

DownloadContentTask task = new DownloadContentTask();
task.execute("http://openweathermap.org/current");


its not working:

DownloadContentTask task = new DownloadContentTask();
task.execute("api.openweathermap.org/data/2.5/weather?q=London");


when I googled, i got

"You can call by city name or city name and country code. API responds with a list of results that match a searching word.
Examples of API calls:


http://api.openweathermap.org/data/2.5/weather?q=London"

can someone please help to get me an appropriate way for API calls. I will be Thankful.

Answer

Read this API Error.You are fetching second error 401.So create an account here Create account.After sign in the account find API Keys.And then use like following :

http://api.openweathermap.org/data/2.5/weather?q=London&appid=Your_API_Key