0

嗨,我可以制作一个 php 函数,我可以在其中传递一组 youtube 链接,并在 youtube 中为某个用户创建一个播放列表,我已经阅读了 youtube 文档,但仍然无法弄清楚。 https://developers.google.com/youtube/2.0/developers_guide_php#Adding_a_Playlist_Video 在文档上显示以下代码。

    $newPlaylist = $yt->newPlaylistListEntry();
$newPlaylist->summary = $yt->newDescription()->setText('description of my new playlist');
$newPlaylist->title = $yt->newTitle()->setText('title of my new playlist');
// post the new playlist
$postLocation = 'http://gdata.youtube.com/feeds/api/users/default/playlists';
try {
  $yt->insertEntry($newPlaylist, $postLocation);
} catch (Zend_Gdata_App_Exception $e) {
  echo $e->getMessage();
}
4

1 回答 1

0

我几乎不是专家,但我认为这就是您要寻找的:

//Make a loop to go over all of the values within the array
     for ($i = 0; $i <= count($array); $i++){
$postUrl = $playlistToAddTo->getPlaylistVideoFeedUrl();
// video entry to be added
$videoEntryToAdd = $yt->getVideoEntry($array[i]);

// create a new Zend_Gdata_PlaylistListEntry, passing in the underling DOMElement of the VideoEntry
$newPlaylistListEntry = $yt->newPlaylistListEntry($videoEntryToAdd->getDOM());

// post
try {
  $yt->insertEntry($newPlaylistListEntry, $postUrl);
} catch (Zend_App_Exception $e) {
  echo $e->getMessage();
}
}

该变量$array显然应该是一个包含 ytvideos 'ID' 的一维数组。希望有帮助。

于 2012-12-30T13:46:04.710 回答