【发布时间】:2017-07-18 15:56:00
【问题描述】:
我正在开发一项 Alexa 技能,该技能使用Pylexa Python 模块以美元的比特币价值进行响应,但每次我在亚马逊的在线技能测试器上调用它时,都会收到以下错误:
There was an error calling the remote endpoint, which returned HTTP 400 : BAD REQUEST
在我的本地机器上尝试,我得到这个错误:
[400] Cert chain URL not valid.
可能是什么问题?如果有帮助,代码将部署在 Heroku 服务器上。我的代码如下,如果有帮助的话(我在另一项技能中使用了类似的代码并且它有效):
import json
import os
import requests
from flask import Flask
from pylexa.app import alexa_blueprint
from pylexa.intent import handle_intent
from pylexa.app import handle_launch_request
from pylexa.response import PlainTextSpeech
app = Flask(__name__)
app.config['app_id'] = os.getenv('ALEXA_APP_ID')
app.register_blueprint(alexa_blueprint)
@handle_intent('GetBTC')
def handle_info_intent(request):
try:
print('Debug: ' + str(request.slots))
btcValue = requests.get('http://api.coindesk.com/v2/bpi/currentprice.json').json()['bpi']['USD']['rate']
print(btcValue)
return PlainTextSpeech("Currently, Bitcoin is worth " + btcValue + " dollars.")
except:
return PlainTextSpeech("I don't know.")
@handle_intent('A')
@handle_launch_request
def handle_start_message(request):
try:
print("New launch!")
btcValue = requests.get('http://api.coindesk.com/v2/bpi/currentprice.json').json()['bpi']['USD']['rate']
print(btcValue)
return PlainTextSpeech("Currently, Bitcoin is worth " + btcValue + " dollars.")
except:
return PlainTextSpeech("I don't know.")
if __name__ == '__main__':
app.run(debug=True)
意图架构:
{
"intents": [
{
"slots": [
{
"name": "BTC",
"type": "CURRENCY"
}
],
"intent": "GetBTC"
}
]
}
任何帮助将不胜感激。
【问题讨论】:
-
端点是什么? SSL 证书是否配置正确?
-
端点是https://echo-btc.herokuapp.com。它使用 Heroku 的通配符证书,我之前使用没有问题。
标签: python heroku gunicorn alexa-skills-kit