Guest User

Untitled

a guest
Dec 15th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. curl
  2. --compressed
  3. -H 'Accept-Encoding:gzip'
  4. -H 'Accept-Language:en-US,en;q=0.5'
  5. --get 'https://places.cit.api.here.com/places/v1/autosuggest'
  6. --data-urlencode 'app_code=my_code'
  7. --data-urlencode 'app_id=my_id'
  8. --data-urlencode 'at=48.13642,11.57755'
  9. --data-urlencode 'pretty=true'
  10. --data-urlencode 'q=Hofbräuhaus am Platz'
  11.  
  12. private void searchForPlacesInMunich(String place) throws IOException {
  13. String link = "https://places.cit.api.here.com/places/v1/autosuggest"
  14. + "?app_id=" + app_id
  15. + "&app_code=" + app_code
  16. + "&at=" + latitude + "%2C" + longitude
  17. + "&q=" + place
  18. + "&pretty";
  19. URL url = new URL(link);
  20. HttpURLConnection con = (HttpURLConnection) url.openConnection();
  21. con.setRequestProperty("Accept-Encoding", "gzip");
  22. con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
  23. con.setRequestMethod("GET");
  24. con.connect();
  25. System.out.println("Length : " + con.getContentLength());
  26.  
  27. Reader reader = null;
  28. if ("gzip".equals(con.getContentEncoding())) {
  29. reader = new InputStreamReader(new GZIPInputStream(con.getInputStream()));
  30. }
  31. else {
  32. reader = new InputStreamReader(con.getInputStream());
  33. }
  34.  
  35. while (true) {
  36. int ch = reader.read();
  37. if (ch==-1) {
  38. break;
  39. }
  40. System.out.print((char)ch);
  41. }
  42. }
Add Comment
Please, Sign In to add comment