I'm building an application with which users can create playlists through drag and drop. I want them to be able to remove videos from a playlist. But I get confused with the docs.
I'm using the youtube api php client library. Keep in mind that the user is logged in.
$youtubeService = new Google_YouTubeService($client);
$playlistItems = $youtubeService->playlistItems;
$deleteVid = $playlistItems->delete($videocode);
And this is the delete function from the client library :
/**
* Deletes a playlist item. (playlistItems.delete)
*
* @param string $id The id parameter specifies the YouTube playlist item ID for the playlist item that is being deleted. In a playlistItem resource, the id property specifies the playlist item's ID.
* @param array $optParams Optional parameters.
*/
public function delete($id, $optParams = array()) {
$params = array('id' => $id);
$params = array_merge($params, $optParams);
$data = $this->__call('delete', array($params));
return $data;
}
There's nowhere, where I can specify which playlist to delete the video from. Does anyone have an idea how to do this? The other playlistItem functions use a Google_PlaylistItem object as a parameter. But this one only a string for the videocode... So weird, can't figure this one out on my own.
Any help would be much appreciated.
PlaylistItemId is unique for the playlist. So same video in two different playlist has two diferent playlistitemId.
https://developers.google.com/youtube/v3/docs/playlistItems
All you need to give is playlistitemId to that function, not the videoId.
You can find playlistitemId from playlistItems->list function specifying the playlist parameter.