엄민용

임시: 개인 인증 없이 API 키만 사용

1 +var {google} =require('googleapis');
2 +
3 +var service = google.youtube('v3');
4 +service.videos.list({
5 + key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518',
6 + part: 'snippet,statistics',
7 + id: 'p5iu1V30myk', // 동영상 Id
8 + fields: 'items(snippet(title))'
9 +}, function(err, response) {
10 + if (err) {
11 + console.log('The API returned an error: ',err);
12 + return;
13 + }
14 +
15 + var video =response.data.items;
16 + if(video.length ==0){
17 + console.log('검색된 동영상이 없습니다.');
18 + } else {
19 + console.log(JSON.stringify(response.data.items[0],null,4));
20 + }
21 +})
...\ No newline at end of file ...\ No newline at end of file