2012-12-30 83 views
0

嗨,我可以做一個PHP函數,我可以通過一系列的YouTube鏈接,它創建一個播放列表在YouTube上爲某個用戶,我已經閱讀YouTube文檔,但仍然無法弄清楚。 https://developers.google.com/youtube/2.0/developers_guide_php#Adding_a_Playlist_Video 對文檔它顯示下面的代碼。從鏈接陣列創建YouTube播放列表

$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(); 
} 

回答

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「標識」的一個維數組。希望有所幫助。