Zend Youtube API - 在单个帐户上上传视频?
我希望允许任何人在我的网站上注册,并在我自己的 YouTube 用户频道上上传他们的视频。
我不希望他们评论任何视频或任何需要自己登录凭据的内容。
我应该使用:ClientLogin 授权吗?
如果是这样,我如何获得令牌,以便我可以允许我的网站与我的 YouTube 频道帐户进行交互?
这里的任何灯光都会非常感激,因为我在这里有点迷路了。
I want to allow anyone register on my site, to upload their videos on my own youtube user channel.
I don't want them to comment any videos, or anything that requires their own login credentials.
Should I use: ClientLogin authorization ?
If so, how can I get a token so that I can allow my site to interact with my youtube channel account?
Any lights here will be greatly appreciated, since I'm kinda lost here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经使用 ClientLogin 完成了此操作。下面是一个基础类。此类返回一个准备发出经过身份验证的请求的 Zend HTTP Client 实例。
您需要定义这些常量:
或者修改类以将它们传入。需要 try/catch 是因为令牌可能会过期,因此您需要一种刷新它们的方法。此外,您还需要发出一个虚拟请求,以确保令牌即使在创建后仍然有效。
请记住,YouTube(嗯,大约 2 年前)阻止您上传视频的时间超过每 10 分钟,这使您的用例变得非常困难。也就是说,您不能允许代表单个帐户上传多个视频,且上传次数不得超过每 10 分钟一次。但自那以后 YouTube 可能已经取消了这一规定。祝你好运
I have accomplished this using ClientLogin. A basic class is below. This class returns an instance of Zend HTTP Client that is ready to make authenticated requests.
You'll need to have these constants defined:
Or modify the class to pass them in. The try/catch is needed because tokens can expire, so you need to a way to refresh them. Also, you need to make a dummy request to ensure the Token is valid even after you create it.
Keep in mind that YouTube (well, as of 2 years ago or so) prevented you from uploading a video more of than every 10 minutes, which makes your use-case pretty difficult. That is, you cannot allow multiple videos being uploaded on a single accounts behalf, more of than every 10 min. But YouTube might have lifted this since then. Good luck
由于我在文档中没有找到 API V3 的任何完整解决方案,因此我一直在互联网上探索解决方案。最后,我将 Python 示例移植到 PHP 中,并为其他有同样问题的人写了一篇关于它的博客文章:
通过 PHP 中的 api 版本 3 将视频上传到 YouTube
本博文使用带有 OAuth2 的 Youtube V3 api,因此您不需要必须担心它被弃用。 V2 中的所有其他功能(ClientLogin、AuthSub 和 OAuth 1.0)自 2012 年 4 月 20 日起全部弃用。
Since I didn't find any complete solutions for API V3 in the documentation I've been exploring the Internet for a solution. In the end I ported the Python example to PHP and wrote a blog post about it for other people that have the same problem:
Uploading a video to youtube through api version 3 in PHP
This blogpost uses the Youtube V3 api with OAuth2 so you don't have to worry about it being deprecated. All other functions (ClientLogin, AuthSub and OAuth 1.0) in V2 are all deprecated as of April 20, 2012.