How to get JSON from URL in Google App Engine Java - json

I want to get json from url in google app engine, can u tell me some quite simple methods to do this, thanks, sr my english not good
URL
Content:
{
"debug_info" : [],
"html_attributions" : [ "Listings by \u003ca href=\"http://www.diadiem.com/\"\u003eDiadiem.com\u003c/a\u003e" ],
"next_page_token" : "ClRMAAAAl7MjfntXhFEi33IPPcZJJ5fYfiJzIIGggr9Xc6A_sKeTrjohJntaaG1jWaGYMKiZYruuoqTVipUZFaLhpNXZbhYloN6SeS44epx3lPRdpuMSEHWJTSO2ShwXOz6bjg0xefcaFOUN9wK6NE5Dykjx-x-VLypkBMRH",
"results" : [
{
"geometry" : {
"location" : {
"lat" : 16.058660,
"lng" : 108.2191410
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "7064cb3f44db62207fc2bd83579b63ca9552e658",
"name" : "Vietcombank - Atm",
"reference" : "CnRwAAAAHU3y6j7CocExwcFq6DKtkS2SFT-0X23E7C9M7bpHk2EF04ShIX7IRNl9TwGF_APSwaKmk8XSZIGm52ajXnpKhj15i48w0BHmJR0ZamJdIAi3iJD_sExjjHkf5Lnfxq4iLroTAmQyRAoAVG7dMwVeTRIQcO_Qq9N85d96vQCtEdZjyRoUbETiZPHxkSjkbD9CVnQh6N_8yUA",
"types" : [ "establishment" ],
"vicinity" : "272 Phan Châu Trinh"
},
{
"geometry" : {
"location" : {
"lat" : 16.0602490,
"lng" : 108.21470
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "bd20b9fbd718c13ee3f6d404c3004b649130df4a",
"name" : "ATM DongA Bank",
"reference" : "CnRtAAAAP9XTDfjgtqvahglz24j2posRRCR9ry56xyAd0FX810ZeyiKWeEi4Btfnfycb23Sa6x_grdjJszB7Xf80jFBrer9kHYQHsKX2-spx9LHn_yrZxlfC7wxHOdUt9YbYMp71fzQ_SJOC9W1Hj2cHHi9g0BIQPrdWzJvelD1NDEcC49Q8eRoUE0juanyzeZHjyYbnozUGB13RySk",
"types" : [ "atm", "finance", "establishment" ],
"vicinity" : "Nguyễn Văn Linh, Da Nang"
},

Not sure if I got your question correctly, but if you are trying to parse Google's JSON response, a good and easy way to do it may be to use jQuery parseJSON function.
You can also take a look at this answered question to see sample code.

Also, not explicitly stated in the "answered question" link above - you cannot just access the json (or xml) from within your web page code even though you can use the url manually in a browser to get the json data (as it seems you have done in your post). There are various security aspects and Google will not even send the data requested that way (I believe it is call cross-site-scripting - Google it for more details). It has to go - as in the example linked above, from you web page to your server, have the server do the request to Google to get the data, have the server then post this back to your site/ web page (through AJAX or just a new page - however you are doing things on your site).
That's the sloppy and non-technical, but I wasted all day Sunday trying to get around this until I understood the issue and what I was supposed to (and had to do). This might not be what you are referring to but I think it may indeed be. If so I hope it helps. Cheers

Related

using a fetched api data in all screens

I'm new on flutter.
Trying to code a city guide application.
I m getting all needed data from web api with one request at startup.
I want to do fetching 1 time and show different parts of data in different screens.
But i cant reach data in all views. As an example, my response is below, i want to send "news" to news.dart, news dart is another screen from the main page.
What kind of architecture should i use?
Maybe creating a singleton class for all data and request it in different views?
My response is something like that;
{
"version" : "1.0",
"news" : [
{
"title" : "title of content 1",
"content" : "content 1"
},
{
"title" : "title of content 2",
"content" : "content 2"
},
],
"cafes" : [
{
"name" : "cafe 1 name",
"image" : "cafe1img.jpg"
},
{
"name" : "cafe 2 name",
"image" : "cafe2img.jpg"
}
]}

Review time is not returned in response

I am using Google Places API to get Place details with reviews. Previously I was getting each review's time in the response.
For example,
"reviews" : [
{
"author_name" : "Robert Ardill",
"author_url" : "https://www.google.com/maps/contrib/106422854611155436041/reviews",
"language" : "en",
"profile_photo_url" : "https://lh3.googleusercontent.com/-T47KxWuAoJU/AAAAAAAAAAI/AAAAAAAAAZo/BDmyI12BZAs/s128-c0x00000000-cc-rp-mo-ba1/photo.jpg",
"rating" : 5,
"relative_time_description" : "a month ago",
"text" : "Awesome offices. Great facilities, location and views. Staff are great hosts",
"time" : 1491144016
}
]
But it looks like, after the new new billing changes in google APIs, the time value is not returned in the response.
Now i m getting a response like the following one
"reviews" : [
{
"author_name" : "Robert Ardill",
"author_url" : "https://www.google.com/maps/contrib/106422854611155436041/reviews",
"language" : "en",
"profile_photo_url" : "https://lh3.googleusercontent.com/-T47KxWuAoJU/AAAAAAAAAAI/AAAAAAAAAZo/BDmyI12BZAs/s128-c0x00000000-cc-rp-mo-ba1/photo.jpg",
"rating" : 5,
"relative_time_description" : "a month ago",
"text" : "Awesome offices. Great facilities, location and views. Staff are great hosts"
}
]
This is the line of code i am using to make the API call
https://maps.googleapis.com/maps/api/place/details/json?key=MY_API_KEY&placeid=MY_PLACE_ID&fields=review
If I remove the fields parameter in the web service call like below, the time value is returned in response with each review data properly.
https://maps.googleapis.com/maps/api/place/details/json?key=MY_API_KEY&placeid=MY_PLACE_ID
This looks like a bug in Google API side. I have subitted a bug in Google issuetracker.
https://issuetracker.google.com/issues/113753944?pli=1

Google Maps Distance Matrix API - Not Returning long/lat in response

Trying out the Google Maps Distance Matrix API for calculating the time between the origin and destination and I'm using this API
https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=32.988777,xxxx&destinations=32.988777,xxxx&key=myAPIKey
(xxxx - I'm providing a valid value just masking it on here)
I am getting a response as
{
"destination_addresses" : [ "Plano, TX 75024, USA" ],
"origin_addresses" : [ "Coppell, TX 75019, USA" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "13.4 mi",
"value" : 21636
},
"duration" : {
"text" : "14 mins",
"value" : 833
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
But I'm unable to correlate the req and response as the response is missing the long/lat, How do I solve this issue?
Per official documentation: DistanceMatrix service does not include lat/lng element in response. See all available elements here: https://developers.google.com/maps/documentation/distance-matrix/intro#DistanceMatrixResponses
Nonetheless, looking at your request, it appears that you already supplied lat/lng in your input. On the other hand if you supplied address as origins/destinations and aiming to extract the corresponding coordinates, then you can simply do forward Geocode afterwards.

Translating engine gives same guids & viewableIDs to diferrent files of complex model

Recently I was trying to implement scenario where I could link views in 3D viewer with views on original revit model.
I zipped linked files and upload them
Upload more times same zip file with changed rootFileName to provide all aspects of a model and translate all
download their manifest.jsons
link views on revit side with view in the viewer using viewableID and uniqueID of original revit view
In here I will provide real shortened examples of manifest outputs
eg file 1.
{
"guid" : "578dd62c-d5dc-8da0-1c75-aa6b0be8ba76",
"name" : "3D pohled",
"success" : "100%",
"hasThumbnail" : "true",
"status" : "success",
"type" : "folder",
"progress" : "complete",
"children" : [{
"guid" : "07e30540-b182-cd58-1c1f-eb46bc58fb9c",
"name" : "{3D}",
"success" : "100%",
"size" : 771479.0,
"hasThumbnail" : "true",
"role" : "3d",
"viewableID" : "8af1141e-a7ca-22b4-d104-d7331a1c0454",
"status" : "success",
"type" : "geometry",
"progress" : "complete",
"children" : [{
"guid" : "429ba882-f0a0-40fa-96e6-c6e02d9fc601-00022cda",
"name" : "{3D}",
"role" : "3d",
"camera" : [22586.240234, 40687.59375, 32810.621094, 54.133858, -29.527559, 16437.923828, -0.160696, -0.29039, 0.943319, 0.547078, 0, 1, 1],
"status" : "success",
"type" : "view",
"progress" : "complete"
}, {
"guid" : "9a3b544b-3c15-9304-f6f8-2c4db7a7dcb3",
"type" : "resource",
"role" : "graphics",
"urn" : "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGVzdGJfMTIzZWUvRkhfRmFzJUMzJUExZGFfdi4wMS56aXA/output/Resource/3D_pohled/_3D_/_3D_.svf",
"mime" : "application/autodesk-svf",
"size" : 680482.0
}
]
}
]
}
eg. file 2
{
"guid" : "578dd62c-d5dc-8da0-1c75-aa6b0be8ba76",
"name" : "3D pohled",
"success" : "100%",
"hasThumbnail" : "true",
"status" : "success",
"type" : "folder",
"progress" : "complete",
"children" : [{
"guid" : "07e30540-b182-cd58-1c1f-eb46bc58fb9c",
"name" : "{3D}",
"success" : "100%",
"size" : 7648740.0,
"hasThumbnail" : "true",
"role" : "3d",
"viewableID" : "8af1141e-a7ca-22b4-d104-d7331a1c0454",
"status" : "success",
"type" : "geometry",
"progress" : "complete",
"children" : [{
"guid" : "429ba882-f0a0-40fa-96e6-c6e02d9fc601-00022cda",
"name" : "{3D}",
"role" : "3d",
"camera" : [40927.800781, 19529.832031, 36075.765625, 54.958988, -27.723097, 16418.119141, -0.359014, -0.171787, 0.917387, 0.320998, 0, 1, 1],
"status" : "success",
"type" : "view",
"progress" : "complete"
}, {
"guid" : "9a3b544b-3c15-9304-f6f8-2c4db7a7dcb3",
"type" : "resource",
"role" : "graphics",
"urn" : "urn:adsk.viewing:fs.file:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGVzdGJfMTIzZWUvRkhfVFpCX1ZaVC56aXA/output/Resource/3D_pohled/_3D_/_3D_.svf",
"mime" : "application/autodesk-svf",
"size" : 7552662.0
}
]
}
]
}
as you see each time URN of file is different, still viewableID and guids are the same. This is not suppose to happen and represents a real problem when working with the information. In manifest.json is also missing information about original revit guid(uniqueid) from which view it was generated, which is needed to uniqely identify view on revit side.
I think it is a bug and needs to be solved and also adding revit view guid into output manifest would help a lot. Because name property is not unique enough, the other guids has no practical use.
Any help would be greatly appreciated
The ids will be the same if they are translated from the same file (i.e. the unique ID used by Revit on its views), regardless the file name. So if you have a .rvt with a view, duplicate this file with different name, translate them both, they will have the same id on that view.
EDIT October 17, 2016
We have updated the translation engine in 9/26/2016 and the viewableID in the bubble is the same as the UniqueId of a Revit View, for both 3d and 2d. That way you can use the viewableId to implement your feature feature.
It is reasonably well known that Revit elements' "unique" ids are not, in fact, true GUIDs. Two copies of a file will have exactly the same "unique" ids for the elements in those files (they are not re-generated on a save-as operation). The purpose of the Unique id in Revit was to provide a mechanism to facilitate worksharing where element ids are not "stable" and may change during a reload latest event where element ids from the central conflict with local Element Ids.
Here is some information from The Building Coder about this topic:
http://thebuildingcoder.typepad.com/blog/2014/04/element-id-export-unique-navisworks-and-other-ids.html#3
In terms of your specific question: "How can i identify, uniquely, the views in revit when traversing manifest.json?" I would suggest that you might (if you have the ability) add the Revit filename as part of the name of the exported view which you have uploaded and translated. Tease that back out of the URN to determine which view you actually have.
If that doesn't work, maybe you could help us better understand this statement:
Upload more times same zip file with changed rootFileName to provide all aspects of a model and translate all
what is this attempting to achieve? different implementations on the viewer side of the same view data? And if so, maybe you can tell us more about exactly what you're trying to ultimately achieve and we can offer some more specific suggestions.

Inconsistent language in Google Place Details API

I'm using Google Place Details API on my server to store information about a place, using the placeId sent by a client.
I'm facing an issue regarding the language of the result, which differs when the place is a city or an address in that city, even when the language is specified in the query. For example:
The place id ChIJ53USP0nBhkcRjQ50xhPN_zw is the city of Milan, and the API returns Milan as locality and Lombardy as administrative area (English names)
The place id EjBWaWEgZGVsbGEgU3BpZ2EsIE1pbGFuLCBQcm92aW5jZSBvZiBNaWxhbiwgSXRhbHk is a street in Milan, and the API returns Milano as locality and Lombardia as administrative area (Italian names)
To make it even weirder, both searches return Italy as country. Is this the expected behavior of the API?
Is this the expected behavior of the API?
Yes, this is expected result. Even if you specify a language, it will return the response in that language only if there is one available, if not it will return the response in the language it was originally entered in.
Case 1:
Milan: As a Milan is city. Therefore,there are available results in almost every language. Almost all the major city through out the world have results in every language. By default, you will get result in English.
Case 2:
Via della Spiga: As it is a street. Right now, the results are only available in Italian as they were most possible entered in Italian.
Result when you search "Via della Spiga" in Google Map:
To learn more about this:
Translation of Places information into language specified by request. In this a request for a feature is asked that tells the developer in which language the results are so that they can take care of data accordingly, I personally think that would be great till the issue has not been fixed.
language parameter in place/details request not working
Both of the above issues are about 2 year old. Yet, Google is unable to resolve this issues.
One way to possibly solve this problem is by using textsearch:
As you can convert most of administrative area/city into any language name by using textsearch:
`https://maps.googleapis.com/maps/api/place/textsearch/json?query=Lombardia&lang‌​uage=Your_language&key=YOUR_API_KEY`
Example: Converting "Lombardia" into a chinese language:
https://maps.googleapis.com/maps/api/place/textsearch/json?query=Lombardia&language=zh-CN&key=YOUR_API
{
"html_attributions" : [],
"results" : [
{
"formatted_address" : "意大利伦巴第",
"geometry" : {
"location" : {
"lat" : 45.47906709999999,
"lng" : 9.8452433
},
"viewport" : {
"northeast" : {
"lat" : 46.6351853,
"lng" : 11.4276993
},
"southwest" : {
"lat" : 44.6796491,
"lng" : 8.4978605
}
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
"id" : "02401d0909d69ca5c69de799e193caf84acc41f9",
"name" : "伦巴第",
"place_id" : "ChIJf4M-GsNEgUcR1JMVKCIm8qY",
"reference" : "CoQBfQAAAEKCAV-1Ec-V2ZfnWsCk_elhlEXckc_k94jBYlU7k5ivhrqPlWd24aSAa5fqNTfwKKhU0wSsZFv42aMm1BrG5wEwZNGKwFqELxMEt0ye7KFfBgVtfHZbqeiBx3hEH8Iq60wwW--edqpROkBTjHrxIwisCGJwhCzKKkQ9H6FdfW_aEhAnmI0ZOFk1KGaGms4IqTOiGhRX5iErBIwnmLos4U9Ggs325MmcEA",
"types" : [ "administrative_area_level_1", "political" ]
}
],
"status" : "OK"
}
Lombardia in chinese is 意大利伦巴第
When you search for placeID details, you get address_components array:
"address_components" : [
{
"long_name" : "Via della Spiga",
"short_name" : "Via della Spiga",
"types" : [ "route" ]
},
{
"long_name" : "Milano",
"short_name" : "Milano",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Milano",
"short_name" : "MI",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Lombardia",
"short_name" : "Lombardia",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "Italy",
"short_name" : "IT",
"types" : [ "country", "political" ]
}
]
So if you loop over the above array and use textsearch then you will get almost consistent address in a particular language.
I think you can use some Optional parameters to set what language you want, such that:
A Nearby Search request is an HTTP URL of the following form:
https://maps.googleapis.com/maps/api/place/nearbysearch/output?parameters
put language parameter, such that:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=cruise&language=en
For more detail, please refer here.