Getting weather information using OpenWeather API

I am creating a weather app using OpenWeather API.
I am using the location sensor to get user coordinates to get the weather of that particular region. However, it results in a runtime error.

WeatherApp1.aia (2.1 MB)

I think you should use responseContent instead of responseCode in the lookup in pairs blocks.

I have tried this, still does not seem to work.

Set If response code is 200 not greater or iqual 400

Still results in this :sob:

You completely changed your blocks. Why did you do that?

Thanks, error no longer shows up. However, nothing is reflected in the respective labels.

We have a lot of topics about using the OpenWeather API. Maybe look at how others did it.

https://community.appinventor.mit.edu/search?q=openweather

Use response, not response content in your list selection blocks

If you want to use dictionary blocks ...a simple example

1 Like

I'm now trying to get the user to type in the region and the latitude and longitude coordinates are found, then using the coordinates, it finds the weather corresponding it. I'm wondering if I have done something wrong because it doesn't seem to work as expected.



WeatherApp1.aia (2.1 MB)

Try these, and show us the two response contents.




By the way, if your response is wrapped in [], its a list and your path should start with 1 for selecting item 1.

What does mean?


How do get the lat and lon values from this?


  • local dict= select item 1 from web2_response
  • lat = lookup 'lat' in local dict
  • lon = lookup 'lon' in local dict

I got this error

Seems to be working now!


image

I added an image that reflects the weather conditions but it is pretty small, yet it shifts all my texts down. Is there anyway to control the sizing and also prevent it from pushing the words below down?

In the Designer, change the Height of the image to 10% of the Screen Height.

Tweak to taste.

Doesn't seem to work. I also noticed that my companion app crashes quite frequently after pressing the "Search" or "Use my location" button.