python twilio HTTPSConnectionPool(host='api.twilio.com', port=443) 超出 url 的最大重试次数


sid = "*****************************"
token = "*****************************"
client = Client(sid, token)
message = client.messages.create(to="+91**********", from_="+12********", body="Hello from twilio")

在运行上面的代码片段时,我收到错误:

啪。SSLError: [SSL: UNKNOWN_PROTOCOL] 未知协议

我正在使用python3.4的虚拟环境运行它。 我不确定这里出了什么问题。

Twilio开发者布道者在这里。

我在这里不完全确定,但我认为您的 TLS 支持可能已经过时了。我使用的是答案而不是评论,因为这会占用更多空间。

您可以尝试从 ubuntu vm 运行以下 python 程序并报告结果吗?

import requests;
print(requests.get('https://www.howsmyssl.com/a/check', verify=False).json()['tls_version']);

编辑

好的,这不是问题,尽管您可以提出请求。你能对requests和 Twilio 端点做同样的事情吗?像这样:

import requests;
request = requests.get('https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json', auth=('YOUR_ACCOUNT_SID', 'YOUR_AUTH_TOKEN'));
print request.json();

这是关于通过http服务器发送请求,我也收到了此错误

答案可在 https://help.pythonanywhere.com/pages/TwilioBehindTheProxy

import os
from twilio.rest import Client
from twilio.http.http_client import TwilioHttpClient
proxy_client = TwilioHttpClient(proxy={'http': os.environ['http_proxy'], 'https': os.environ['https_proxy']})
account_sid = 'your account id here'
auth_token = 'your twilio token here'
client = Client(account_sid, auth_token, http_client=proxy_client)
# twilio api calls will now work from behind the proxy:
message = client.messages.create(to="...", from_='...', body='...')

最新更新