Python 3.x 如何发送Zoom.us会议的近距离字幕?
我一直在尝试按照Zoom的说明进行操作,但每次尝试发送标题时都会返回400个错误Python 3.x 如何发送Zoom.us会议的近距离字幕?,python-3.x,closed-captions,accessible,Python 3.x,Closed Captions,Accessible,我一直在尝试按照Zoom的说明进行操作,但每次尝试发送标题时都会返回400个错误 {“时间戳”:1594640701018,“状态”:400,“错误”:“错误请求”,“消息”:“无可用消息”,“路径”:“/closedcaption”} 文档中说,当会议还没有开始时,400会返回,但在我的测试场景中,我有两个设备连接到会议,我正在从主机复制闭路字幕API令牌,然后将其提供给我的测试程序。据我所知,这是一个开始的会议,所以一定有别的事情。我多次尝试发送请求,但仍然返回400个错误 我使用的是Pyt
{“时间戳”:1594640701018,“状态”:400,“错误”:“错误请求”,“消息”:“无可用消息”,“路径”:“/closedcaption”}
文档中说,当会议还没有开始时,400会返回,但在我的测试场景中,我有两个设备连接到会议,我正在从主机复制闭路字幕API令牌,然后将其提供给我的测试程序。据我所知,这是一个开始的会议,所以一定有别的事情。我多次尝试发送请求,但仍然返回400个错误
我使用的是Python3,我尝试了urllib.request
和http.client
,但都没有成功。我错过了什么
导入urllib.request
导入http.client
第三方api令牌=输入(“第三方CC令牌:”)
域=第三方api令牌。拆分('/')[2]
如果第三方api令牌中的“https://”:
域=域+':443'
其他:
域=域+':80'
序号=1
尽管如此:
输入('按Enter键继续')
格式化的url='{}&lang=en-US&seq={}'。格式(缩放url,seq)
#格式化的文本='Hello World\n'。编码('utf-8')
格式化的\u text='Hello World\n'
标题={'Content-Type':'text/plain'}
打印(域)
打印(格式化的url)
尝试:
#r=urllib.request.request(格式化的url,数据=格式化的文本,标题=标题,方法='POST')
#使用urllib.request.urlopen(r)作为响应:
#打印(response.read().decode('utf-8'))
conn=http.client.HTTPSConnection(域)
conn.request(“POST”,格式化的url.replace(域“”),body=格式化的文本,headers=头)
res=conn.getresponse()
data=res.read()
打印(数据解码(“utf-8”))
例外情况除外,如e:
打印(e)
序号+=1
在代码中保留了一个旧的变量名,当我删除它时可以正常工作。
以下代码可供参考:
import urllib.request
import http.client
third_party_api_token = input('Third Party CC Token: ')
domain = third_party_api_token.split('/')[2]
if 'https://' in third_party_api_token:
domain = domain + ':443'
else:
domain = domain + ':80'
seq = 1
while True:
input('Press Enter to continue')
formatted_url = '{}&lang=en-US&seq={}'.format(third_party_api_token , seq)
# formatted_text = 'Hello World\n'.encode('utf-8')
formatted_text = 'Hello World\n'
headers = {'Content-Type':'text/plain'}
print(domain)
print(formatted_url)
try:
# r = urllib.request.Request(formatted_url, data=formatted_text, headers=headers, method='POST')
# with urllib.request.urlopen(r) as response:
# print(response.read().decode('utf-8'))
conn = http.client.HTTPSConnection(domain)
conn.request("POST", formatted_url.replace(domain, ''), body=formatted_text, headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
except Exception as e:
print(e)
seq += 1
在代码中留下了一个旧的变量名,当我删除它时可以正常工作。 以下代码可供参考:
import urllib.request
import http.client
third_party_api_token = input('Third Party CC Token: ')
domain = third_party_api_token.split('/')[2]
if 'https://' in third_party_api_token:
domain = domain + ':443'
else:
domain = domain + ':80'
seq = 1
while True:
input('Press Enter to continue')
formatted_url = '{}&lang=en-US&seq={}'.format(third_party_api_token , seq)
# formatted_text = 'Hello World\n'.encode('utf-8')
formatted_text = 'Hello World\n'
headers = {'Content-Type':'text/plain'}
print(domain)
print(formatted_url)
try:
# r = urllib.request.Request(formatted_url, data=formatted_text, headers=headers, method='POST')
# with urllib.request.urlopen(r) as response:
# print(response.read().decode('utf-8'))
conn = http.client.HTTPSConnection(domain)
conn.request("POST", formatted_url.replace(domain, ''), body=formatted_text, headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
except Exception as e:
print(e)
seq += 1