I created using googlemap api program.
I didn't restrict api in develop.
I deployed the program to server then I turned on api restrict.
the program looks like a little slow and sometimes miss response.
I need stop a second for the program?
Or is the setting bad?
def nearbysearch(apikey, place, centerlatlng, types, radius):
'''
dependency
----------
Places API
parameters
----------
place: tokyo
return
--------
a place\n
place_id, rating\n
e.g. CmRaAAAARRAYThPn0sTB1aE-Afx0_..., 4
'''
url = 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?' \
'location={}&radius={}&type={}&keyword={}&' \
'key={}'
url = url.format(centerlatlng, radius, types, urllib.parse.quote(place), apikey)
# print("nearbysearch:", url)
res = urllib.request.urlopen(url)
////////////// time.sleep(1) ////////////// <- need??
retvalue = None
if res.code == 200:
res_json = json.loads(res.read())
if res_json.get("results"):
retvalue = res_json["results"]
return retvalue
query: ramen as japanese langage at shibuya
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=35.6557695,139.7017417&radius=1500&type=restaurant&keyword=%E3%83%A9%E3%83%BC%E3%83%A1%E3%83%B3&key=MY_API_KEY
miss responce:
{
"error_message" : "API keys with referer restrictions cannot be used with this API.",
"html_attributions" : [],
"results" : [],
"status" : "REQUEST_DENIED"
}
setting: localhost is not working at restrict
http://127.0.0.1:8000/*
http://www.henojiya.net/*
http://www.henojiya.net/gmarker/