我試圖使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