我一直在尝试按照Zoom的website上的说明进行操作,但每次我尝试发送字幕时都会收到400错误提示。
{"timestamp":1594640701018,"status":400,"error":"Bad Request","message":"No message available","path":"/closedcaption"}
文档显示,当会议尚未开始时,400将返回,但在我的测试场景中,我有两个设备连接到会议,并且在将隐藏字幕API令牌提供给我的测试程序之前,我从主机复制它。据我所知,这是一个开始的会议,所以一定有其他事情要做。我已经多次尝试发送请求,但仍然收到400个错误。
我使用的是Python3,我尝试过urllib.request和http.client,但都没有用。我遗漏了什么?
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(zoom_cc_url, 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发布于 2020-07-13 20:32:08
在代码中保留了一个旧的变量名,当我删除它时,它工作得很好。作为参考,下面的代码可以工作:
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 += 1https://stackoverflow.com/questions/62875415
复制相似问题