0

こんにちは、YouTube リンクの配列を渡すことができる PHP 関数を作成して、特定のユーザーのために 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」を含む1次元配列である必要があります。お役に立てば幸いです。

于 2012-12-30T13:46:04.710 に答える