简体   繁体   English

我可以使用 tweepy 发送 mp4 文件吗?

[英]Can I tweet mp4 files with tweepy?

I was just wondering if it was possible to tweet an mp4 file with tweepy (maybe using api.update_with_media ).我只是想知道是否可以使用api.update_with_media mp4 文件(也许使用api.update_with_media )。 I've seen a post from a few years ago saying that it's not possible with the official tweepy, but I find it really hard to believe that there's no way to do it with the official tweepy.几年前我看到一个帖子说官方 tweepy 是不可能的,但我发现很难相信官方 tweepy 没有办法做到这一点。 Can anyone please help?有人可以帮忙吗?

update_with_media was deprecated as a Twitter API method about 5 years ago.大约 5 年前, update_with_media作为 Twitter API 方法被弃用。 This pre-dated the ability to upload GIFs and video MP4s.这早于上传 GIF 和视频 MP4 的能力。 If you want to post media on Twitter via the API, you must find a library that supports the media upload endpoints (and chunked uploads).如果您想通过 API 在 Twitter 上发布媒体,您必须找到一个支持媒体上传端点(和分块上传)的库。 The process is过程是

  • upload the media file (chunked if necessary depending on size and format)上传媒体文件(必要时根据大小和格式分块)
  • retrieve a media ID string检索媒体 ID 字符串
  • post a Tweet, and add the media ID to the Tweet.发布推文,并将媒体 ID 添加到推文。

Note that you can only post multiple images on a single Tweet;请注意,您只能在一条推文上发布多张图片; you can only post a single GIF or video file on a single Tweet, not multiple.您只能在一条推文上发布一个 GIF 或视频文件,而不能发布多个。

I do not believe the default Tweepy release supports this but I could be wrong, you'll need to check the Tweepy documentation.我不相信默认的 Tweepy 版本支持这一点,但我可能错了,您需要查看 Tweepy 文档。

Do NOT use update_with_media - it's very old and unsupported as an API path.不要使用update_with_media - 它非常旧并且不支持作为 API 路径。

Also worth being aware that tweepy itself is a third party library - that we at Twitter LOVE - but this is not officially supported.还值得一提的是,tweepy 本身是一个第三方库——我们在 Twitter 上很喜欢——但这并没有得到官方支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM