0
我试图在Google Places API中POST check-in request。他们描述了它的方式,我有权要求本 -Google Places在Python中签入POST请求
POST https://maps.googleapis.com/maps/api/place/check-in/json?sensor=true_or_false&key=AddYourOwnKeyHere HTTP/1.1
Host: maps.googleapis.com
{
"reference": "place_reference"
}
我当前的代码看起来是这样的 -
def checkin(self, reference="", sensor="true"):
"""
"""
base_url = "https://maps.googleapis.com/maps/api/place/check-in/json"
params = urllib.urlencode(
{
'key': self.API_KEY,
'sensor': sensor,
}
)
post_url = base_url + "?" + params
headers = { 'Host': "maps.googleapis.com" }
data = urllib.urlencode({ 'reference': reference })
req = Request(post_url, data, headers)
response = urllib2.urlopen(req)
resp = response.read()
但我不断收到错误 -
urllib2.HTTPError: HTTP Error 400: Bad Request
我是什么做错了?
有没有在您的变量中的任何尾随空白要传递呢? – 2012-03-28 07:59:00
无尾随空白。 – 2012-03-28 08:13:07