Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void sendRequest() throws ParseException, JSONException
- {
- try {
- String Service = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=24.698884,46.717719&radius=50000&language=ar&types=food&sensor=true&key=AIzaSyDuQJDY4Ym5CgyDdUa7s6TQzO5wKRKFrgE";
- URL url = new URL(Service);
- BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
- String line;
- StringBuffer response = new StringBuffer();
- line = reader.readLine();
- while ((line = reader.readLine()) != null) {
- System.out.println(line);
- JSONParser jsonParser = new JSONParser();
- JSONObject jsonObject = (JSONObject) jsonParser.parse(line);
- String name = (String) jsonObject.get("name");
- String vicinity = (String) jsonObject.get("vicinity");
- String icon = (String) jsonObject.get("icon");
- long rating= (long)jsonObject.get("rating");
- }
- reader.close();
- } catch (MalformedURLException e) {
- e.printStackTrace() ;
- } catch (IOException e) {
- e.printStackTrace() ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement