0

I am trying to get API data using this simple code:

while (true)
{
  BufferedReader br = new BufferedReader(new InputStreamReader(new 
  URL("https://api.darksky.net/forecast/f34171a387dbb5f4a29c66f6adc52e2f /49.133333,6.16667")
      .openStream()));

   String temp = br.readLine();
   MyAPI = new JSONObject(strTemp);
   System.out.println(MyAPI.getJSONObject("currently").getLong("time"));

   br.close();
   Thread.sleep(5000);
}

Normally the "time" I get should be different each time I request the API.

It is OK when I use a web browser to request the API, but with my java application I always receive the same data all day long.VP

Did I miss something?

1 Answer 1

1

your URL

URL("https://api.darksky.net/forecast/f34171a387dbb5f4a29c66f6adc52e2f /49.133333,6.16667")

suppose not to have a space

URL("https://api.darksky.net/forecast/f34171a387dbb5f4a29c66f6adc52e2f/49.133333,6.16667")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.