Created
October 6, 2015 18:43
-
-
Save msomu/28cc8068a027cbccdfd6 to your computer and use it in GitHub Desktop.
this is how url should be appended
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Will contain the raw JSON response as a string. | |
| String forecastJsonStr = null; | |
| String format = "json"; | |
| String units = "metric"; | |
| int numDays = 7; | |
| // Construct the URL for the OpenWeatherMap query | |
| // Possible parameters are avaiable at OWM's forecast API page, at | |
| // http://openweathermap.org/API#forecast | |
| //URL url = new URL("http://api.openweathermap.org/data/2.5/forecast/daily?q=94043&mode=json&units=metric&cnt=7"); | |
| final String FORECAST_BASE_URL = | |
| "http://api.openweathermap.org/data/2.5/forecast/daily?"; | |
| final String QUERY_PARAM = "q"; | |
| final String FORMAT_PARAM = "mode"; | |
| final String UNITS_PARAM = "units"; | |
| final String DAYS_PARAM = "cnt"; | |
| Uri builtUri = Uri.parse(FORECAST_BASE_URL).buildUpon() | |
| .appendQueryParameter(QUERY_PARAM,params[0]) | |
| .appendQueryParameter(FORMAT_PARAM,format) | |
| .appendQueryParameter(UNITS_PARAM,units) | |
| .appendQueryParameter(DAYS_PARAM,Integer.toString(numDays)) | |
| .build(); | |
| URL url = new URL(builtUri.toString()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment