YouTube API getPlaylistVideoFeedUrl 问题
我想使用 GData 将视频添加到播放列表。所以我创建播放列表没有问题,但我无法向其中添加视频。 这就是我所做的:
$playlist = $yt->newPlaylistListEntry();
$playlist->summary = $yt->newDescription()->setText("test");
$playlist->title = $yt->newTitle()->setText("test2");
$postLocation = 'http://gdata.youtube.com/feeds/api/users/default/playlists';
$yt->insertEntry($playlist, $postLocation);
$feedUrl = $playlist->getPlaylistVideoFeedUrl();
$videoEntryToAdd = $yt->getVideoEntry(..given id here..);
$newPlaylistListEntry = $yt->newPlaylistListEntry($videoEntryToAdd->getDOM());
$yt->insertEntry($newPlaylistListEntry, $feedUrl);
我收到以下错误:
注意:尝试在第 296 行获取 C:...\library\Zend\Gdata\YouTube\PlaylistListEntry.php 中非对象的属性
这是由以下代码引起的:
$feedUrl = $playlist->getPlaylistVideoFeedUrl();
var_dump
显示 < code>$feed_url 为 NULL。而且它显示 $playlist
是一个对象 Zend_Gdata_YouTube_PlaylistListEntry
,所以我无法理解为什么它写“非对象的属性”。
I would like to add a video to a playlist using GData. So I have no problem creating the playlist, but I can't manage to add a video to it.
Here's what I do:
$playlist = $yt->newPlaylistListEntry();
$playlist->summary = $yt->newDescription()->setText("test");
$playlist->title = $yt->newTitle()->setText("test2");
$postLocation = 'http://gdata.youtube.com/feeds/api/users/default/playlists';
$yt->insertEntry($playlist, $postLocation);
$feedUrl = $playlist->getPlaylistVideoFeedUrl();
$videoEntryToAdd = $yt->getVideoEntry(..given id here..);
$newPlaylistListEntry = $yt->newPlaylistListEntry($videoEntryToAdd->getDOM());
$yt->insertEntry($newPlaylistListEntry, $feedUrl);
And I get the following error:
Notice: Trying to get property of non-object in C:...\library\Zend\Gdata\YouTube\PlaylistListEntry.php on line 296
Which is caused by this code:
$feedUrl = $playlist->getPlaylistVideoFeedUrl();
var_dump
shows that the $feed_url
is NULL. And it shows that $playlist
is an object Zend_Gdata_YouTube_PlaylistListEntry
, so I can't understand why it writes "property of non-object".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来这是 API 中的某种错误。所以我做了一些解决方法。它可能看起来很丑,但我没有其他想法。
简单地这样称呼它:
It seems like it is some kind of a bug in the API. So I've made a little workaround. It may seem ugly, but I had no other ideas.
And simply call it like that: