I'm trying to use Google's API for geolocation giving wifi data to determine location. This is their intro. And this is my code
@author: Keith
"""import requestspayload = {"considerIp": "false","wifiAccessPoints": [{"macAddress": "00:25:9c:cf:1c:ac","signalStrength": -43,"signalToNoiseRatio": 0},{"macAddress": "00:25:9c:cf:1c:ad","signalStrength": -55,"signalToNoiseRatio": 0}],'key':'<MyAPIKey>'
}
r = requests.post('https://www.googleapis.com/geolocation/v1/geolocate',
params=payload)
print(r.text)
This is the output
{"location": {"lat": 32.3643098,"lng": -88.703656},"accuracy": 6061.0
}
The request ignored all of the payload except the key portion and just found the geolocation using my IP address. So I'm sending the json payload incorrectly. I know this is probably really simple, but I'm stuck and couldn't find an example of python being used with requests to do this type of API query. Thanks
Edit: Picked up the cURL library and executed this command with success:
curl -d @your_filename.json -H "Content-Type: application/json" -i "https://www.googleapis.com/geolocation/v1/geolocate?key=<myapikey>"
and got the output I expected. I just want to be able to do the same thing in requests, but the data I'm trying to send is in "your_filename.json".