问题描述
我正在使用 Zend_Gdata_YouTube 与 YouTube API 交互以从我的网站上传视频.视频上传为私人":
I'm using Zend_Gdata_YouTube to interface with the YouTube API to upload videos from my site. The videos are uploaded as "private":
$myVideoEntry->setVideoPrivate();
...并且有独特的标签和开发者标签.然后,管理员可以进入自定义 CMS 并批准用户提交的私人条目并将其设为公开 - 至少,这就是我想要做的.
...and have unique tags and developer tags. An admin can then go into a custom CMS and approve the private user-submitted entries and make them public - at least, that's what I want to do.
在 CMS 中,我以经过身份验证的用户 (Zend_Gdata_AuthSub) 的身份连接到 API.我可以像这样提取经过身份验证的用户的视频:
In the CMS, I connect to the API as an authenticated user (Zend_Gdata_AuthSub). I can pull the authenticated user's video like so:
$videoFeed = $yt->getuserUploads('default');
这将拉取所有视频,包括私人和公共视频.但是当我尝试使用搜索词搜索特定视频时:
This will pull all the videos, both private and public. But when I try to search for a specific video with a search term:
$query = $yt->newVideoQuery();
$query->setSafeSearch('none');
$query->setVideoQuery('puppies');
$videoFeed = $yt->getVideoFeed($query->getQueryUrl(2));
或按标签:
$query = $yt->newVideoQuery();
$query->setOrderBy('viewCount');
$query->setRacy('include');
$query->setCategory('People/sometag');
// obtain a feed with videos matching the provided tag
$videoFeed = $yt->getVideoFeed($query);
或按开发者标签:
$devTagUrl = 'http://gdata.youtube.com/feeds/api/videos/-/%7Bhttp%3A%2F%2Fgdata.youtube.com' .
'%2Fschemas%2F2007%2Fdevelopertags.cat%7D' . $some_dev_tag;
$videoFeed = $yt->getVideoFeed($devTagUrl);
私人视频将返回空结果.但是,如果我公开视频,那么我可以从上述三种方法中的任何一种中提取它 - 所有这些都是在经过身份验证的连接下执行的.
The private videos will return an empty result. However, if I make the video public, then I can pull it from any of the three methods above - all of which are being executed under an authenticated connection.
如何根据标签或开发者标签拉取私人视频?我错过了什么吗?非常感谢!!
How can I pull a private video based on tag or developer tag? Am I missing something? Thanks so much!!
推荐答案
不幸的是,这似乎是 API 的限制.我的解决方案是通过以下方式提取所有用户的视频:
Unfortunately this seems to be a limitation of the API. My work around solution was to pull all the user's videos with:
$videoFeed = $yt->getuserUploads('default');
其中拉出公共和私人视频.然后我将我的开发标签与每个条目进行比较,并匹配 PHP 中的视频.
Which pulls the public and private videos. Then I compare my dev tags with each entry and match up the videos in PHP.
这篇关于YouTube API (PHP) - 在我的帐户下检索私人视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!