标题基本上概括起来了,我向google翻译api提出了如下请求:
payload = {"key":translate_api_key, "q":str(sentence)}
try:
api_response = requests.get("https://www.googleapis.com/language/translate /v2/detect", params=payload)
except Exception, e:
print e这正常工作(我的意思是将它作为脚本运行在我的桌面上),但是在google应用程序引擎服务器上,我得到了这样的响应:
{u'error': {u'message': u'SSL is required to perform this operation.', u'code': 403, u'errors': [{u'message': u'SSL is required to perform this operation.', u'domain': u'global', u'reason': u'sslRequired'}]}}我怎么才能解决这个问题?
编辑:似乎请求的https不能很好地处理GAE。使用urlfetch和urllib似乎可以解决这个问题。
payload = dict(key=translate_api_key, q=sentence)
payload = urllib.urlencode(payload)
url = "https://www.googleapis.com/language/translate/v2/detect?"
api_response = urlfetch.fetch(url+payload)发布于 2014-06-04 18:52:48
您可以在app.yaml中尝试
handlers:
- url: /youraccount/.*
script: accounts.py
login: required
secure: alwayssecure:always使成为您的站点ssl。但我不确定这是真正的问题。
https://stackoverflow.com/questions/24043784
复制相似问题