我想用javascript向youtube上传video,如何做?
我现在的进展是可以用js查看用户的video,但是用户不能上传video,我希望用户可以通过js上传video,我调用了google js api " https://apis.google.com/js/client.js?onload=googleApiClientReady " 想用youtube v3的api https://developers.google.com/youtube/v3/docs/videos/insert 这个来插入,我现在查看video upload list的代码如下,问如何插入video?
function handleAPILoaded() {
requestUserUploadsPlaylistId();
}
//Retrieve the uploads playlist id.
function requestUserUploadsPlaylistId() {
// https://developers.google.com/youtube/v3/docs/channels/list
var request = gapi.client.youtube.channels.list({
// mine: '' indicates that we want to retrieve the channel for the authenticated user.
mine: '',
part: 'contentDetails'
});
request.execute(function(response) {
playlistId = response.result.items[0].contentDetails.uploads;
requestVideoPlaylist(playlistId);
});
}
// Retrieve a playist of videos.
function requestVideoPlaylist(playlistId, pageToken) {
$('#video-container').html('');
var requestOptions = {
playlistId: playlistId,
part: 'snippet',
maxResults: 9
};
if (pageToken) {
requestOptions.pageToken = pageToken;
}
var request = gapi.client.youtube.playlistItems.list(requestOptions);
视频 json youtube-api JavaScript
小白白白白
10 years, 10 months ago