Question

blackI have a python script that conducts a places search. With curl, the script will return results exactly twice, then begins to return REQUEST_DENIED. If I make a small change to the script (literally by adding a space to the end of a line which does nothing), I can run the script with curl and retrieve results two more times, then again REQUEST_DENIED.

If I simply run the script locally (python search.py on command line with nearby_search(45,45) added to the end of the search.py file, I can get an unlimited number of results.

Techincals: So, I use this curl command to invoke some operation on my webserver: curl -X PUT -H "Content-Type: application/json" -d "{\"user_id\":\"foo\"}" localhost:8080/location/?lat=50&lon=50 Which routes to: main.py @bottle.route('/location/', method='PUT') def location() : user_id = request.json["user_id"] lon = request.query["lon"] lat = request.query["lat"] nearby_places = nearby_search(lon,lat) return nearby_places And the nearby searches method: searches.py def nearby_search (lon, lat) : search_url='https://maps.googleapis.com/maps/api/place/nearbysearch/json?radius=' search_url = search_url + str(radius) + '&location=' + str(lon) + ',' + str(lat) + '&sensor=false&key=%s' % API_KEY search_response = urllib.urlopen(search_url) response_json = json.load(search_response) return response_json

Anyhow, I can run this curl command exactly two times and get results (actual nearby places data). However, a third curl command will give me a REQUEST_DENIED. When I make the same http request from an Android device (to my server), same thing (if i haven't made the request from curl yet). Two searches and then forever REQUEST_DENIED.

Also, I know I am not 'PUT'ting anything in a database anywhere but I intend to, hence the PUT.

My question is: What is going on? Why am I getting request denied after two requests and why does making a small change that affects the script in no way allowing me to make two more requests?

Update1 I changed my /location/ endpoint to handle GET requests instead of PUT, still, same issue. Update2 Generated a new API key, still no luck.
Update3 Well, I tried using a browser key in hopes that it would serve as a workaround...No luck.

Was it helpful?

Solution

solved by using https://github.com/slimkrazy/python-google-places. most likely an issue with not closing the connection to google after receiving the response

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top