我试图使youtube.search.list
与Node.js
一起使用。它看起来像我可以用YouTube API
v.3.0成功验证,但是当我运行youtube.search.list
时,我得到空的结果集。如何使用Node.js实现youtube.search.list
有代码中的愚蠢的错误或我做出不正确的请求YouTube API
。
下面是代码:
var google = require('googleapis');
var youtubeV3 = google.youtube({ version: 'v3', auth: 'MY_API_KEY' });
var request = youtubeV3.search.list({
part: 'snippet',
type: 'video',
q: 'Cat',
maxResults: 50,
order: 'date',
safeSearch: 'moderate',
videoEmbeddable: true
});
// console.log('Here we start search');
for (var i in request.items) {
var item = request.items[i];
console.log('Title: ', item.id.videoId, item.snippet.title);
}
为了检查我从API回去我跑console.log(request)
,并得到空对象。
我没有这方面的经验,但我会检查https://developers.google.com/youtube/v3/code_samples/javascript#search_by_keyword 我认为应该有一个execute()才能得到结果,祝你好运并报告回来,如果你得到它的工作。 – diynevala
@diynevala,我在你引用的资源上花了很多钱,没有积极的结果 – IgorM