【问题标题】:create youtube playlist from array of links从链接数组创建 youtube 播放列表
【发布时间】:2012-12-30 12:44:38
【问题描述】:

嗨,我可以创建一个 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();
}

【问题讨论】:

    标签: php arrays youtube youtube-api playlist


    【解决方案1】:

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

    //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' 的一维数组。希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 2021-11-19
      • 1970-01-01
      • 2018-01-15
      • 2016-08-23
      • 2011-10-14
      • 2015-11-16
      • 2020-10-02
      • 2018-07-24
      • 1970-01-01
      相关资源
      最近更新 更多