使用 Zend 在 YouTube 上创建私人播放列表

发布于 2024-10-11 08:59:44 字数 1594 浏览 6 评论 0原文

我正在拼命尝试在 YouTube 上创建一个私人播放列表。创建公共播放列表没问题,文档非常好。但是,我无法将说明“翻译”为代码。

您可以使用 API 来更新 播放列表的标题、描述和/或 公共/私人状态。要更新一个 播放列表,修改PlaylistListEntry 该播放列表的对象,然后调用 对象的 save 方法。

我的代码:

$httpClient = isset($_SESSION['sessionToken'])? Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']) : null;
$this->youtube = new Zend_Gdata_YouTube($httpClient, "CompanyName-AppName-0.1", null, $this->apikey);

// ...

$yt = $this->youtube;
$newPlaylist = $yt->newPlaylistListEntry();
$newPlaylist->description = $yt->newDescription()->setText('My Description');
$newPlaylist->title = $yt->newTitle()->setText('My Title');

$postLocation = 'http://gdata.youtube.com/feeds/api/users/default/playlists';
try {
    $yt->insertEntry($newPlaylist, $postLocation);
} catch (Zend_Gdata_App_Exception $e) {
    echo $e->getMessage();
}

最后一部分或多或少是文档中的示例代码。它效果很好,但播放列表是公开的。

据我了解, $newPlaylistPlaylistListEntry 的实例,因此应该有一种方法将其设为私有。我检查了对象源代码(及其超过 9000 个父对象)以及 get_class_methods 的输出,但是我发现没有任何方法使其成为私有的。另外,仅仅尝试将私有/公共成员设置为 true/false 没有帮助,并会导致错误消息(说没有这样的成员)。

我对 YouTube API 和 Zend 不太有经验,如果有人能在这里帮助我,我真的很感激。

根据我的阅读,可以通过添加 标记到请求。这听起来很简单,有没有办法手动将其添加到请求中?

I'm desperately trying to create a private playlist on youtube. It's no problem to create public playlists, the docs are very good. However I'm unable to "translate" the instructions to code.

You can use the API to update a
playlist's title, description and or
public/private status. To update a
playlist, modify the PlaylistListEntry
object for that playlist and then call
the object's save method.

My code:

$httpClient = isset($_SESSION['sessionToken'])? Zend_Gdata_AuthSub::getHttpClient($_SESSION['sessionToken']) : null;
$this->youtube = new Zend_Gdata_YouTube($httpClient, "CompanyName-AppName-0.1", null, $this->apikey);

// ...

$yt = $this->youtube;
$newPlaylist = $yt->newPlaylistListEntry();
$newPlaylist->description = $yt->newDescription()->setText('My Description');
$newPlaylist->title = $yt->newTitle()->setText('My Title');

$postLocation = 'http://gdata.youtube.com/feeds/api/users/default/playlists';
try {
    $yt->insertEntry($newPlaylist, $postLocation);
} catch (Zend_Gdata_App_Exception $e) {
    echo $e->getMessage();
}

The last part is more or less the sample code from the docs. It works great, but the playlist is public.

From what I understand, $newPlaylist is an instance of PlaylistListEntry and thus there should be a method to make it private. I've inspected the object source code (and its over 9000 parent objects) plus the output of get_class_methods, however I found no method which makes it private. Also just trying to set the private/public member to true/false doesn't help and leads to an error message (saying there's no such member).

I'm not very experienced with the YouTube API and Zend, I'd really appreciate if someone could help me out here.

From what I've read making a playlist private can be done by adding a <yt:private /> tag to the request. This sounds pretty simple, is there maybe a way to manually add it to the request?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

偏爱自由 2024-10-18 08:59:44

我不确定播放列表,但一个特定的视频可以在上传时被标记为“私人”:

$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$myVideoEntry->setMediaSource($filesource);
$myVideoEntry->setVideoTitle($video_title);
// ... etc ...
$myVideoEntry->setVideoPrivate();

我知道您正在搜索播放列表,但也许它可以帮助您......例如通过分析代码该方法等

I'm not sur about playlist, but one particural video could be marked like a "private" in the moment of upload by:

$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$myVideoEntry->setMediaSource($filesource);
$myVideoEntry->setVideoTitle($video_title);
// ... etc ...
$myVideoEntry->setVideoPrivate();

I know that you are searching about playlist, but maybe it could help you... for example by analizing code of this method, etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文