Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- curl
- --compressed
- -H 'Accept-Encoding:gzip'
- -H 'Accept-Language:en-US,en;q=0.5'
- --get 'https://places.cit.api.here.com/places/v1/autosuggest'
- --data-urlencode 'app_code=my_code'
- --data-urlencode 'app_id=my_id'
- --data-urlencode 'at=48.13642,11.57755'
- --data-urlencode 'pretty=true'
- --data-urlencode 'q=Hofbräuhaus am Platz'
- private void searchForPlacesInMunich(String place) throws IOException {
- String link = "https://places.cit.api.here.com/places/v1/autosuggest"
- + "?app_id=" + app_id
- + "&app_code=" + app_code
- + "&at=" + latitude + "%2C" + longitude
- + "&q=" + place
- + "&pretty";
- URL url = new URL(link);
- HttpURLConnection con = (HttpURLConnection) url.openConnection();
- con.setRequestProperty("Accept-Encoding", "gzip");
- con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
- con.setRequestMethod("GET");
- con.connect();
- System.out.println("Length : " + con.getContentLength());
- Reader reader = null;
- if ("gzip".equals(con.getContentEncoding())) {
- reader = new InputStreamReader(new GZIPInputStream(con.getInputStream()));
- }
- else {
- reader = new InputStreamReader(con.getInputStream());
- }
- while (true) {
- int ch = reader.read();
- if (ch==-1) {
- break;
- }
- System.out.print((char)ch);
- }
- }
Add Comment
Please, Sign In to add comment