python - YouTube发送实时聊天消息不起作用

标签 python youtube youtube-api youtube-livestreaming-api

youtube.liveChatMessages().insert返回400错误代码,原因是unexpectedPart

这与在Google API资源管理器中收到的响应相同。

def send_message(youtube):
  send_message_response = youtube.liveChatMessages().insert (
     part = "snippet",
     body = dict (
        snippet = dict(
           liveChatId = result_chatId,
           type = "textMessageEvent",
           textMessageDetails = dict(
               messageText = "hello world"
           )
         ),
         authorDetails = dict(
             displayName = "blabla"
         )
      )
   ).execute()

   print "%s" % (send_message_response)

Error response received.



Error Response

最佳答案

我很确定authorDetails资源是从API返回的字典,其中提供了有关聊天消息作者的详细信息。它仅从GET请求中返回,并且永远不能作为POST或PUT请求中的参数添加,因为该数据无法更改。

关于python - YouTube发送实时聊天消息不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36931319/

相关文章:

python - 使用unittest.mock.patch时,为什么autospec默认不是True?

python - 对 pandas 中相同的列名进行分组

php - 如何为使用YouTube数据API v3 php上传的视频启用获利功能?

php - 尝试使用 YouTube API 时出现需要登录错误

youtube - 无法使用API​​ v3将YouTube与我们的应用程序集成

python - 如何设置 matplotlib 颜色条范围?

python - numpy 修剪字节字符串中的尾随零

youtube - 如何提供像 Youtube 这样的视频?几乎即时播放和快速搜索

css - YouTube iframe 背景中的响应高度

javascript - YouTube Javascript API 在 iPad iOS8 上无法按预期工作