2015-09-16 77 views

回答

3

我設法做到了!

下面是代碼,以防有人在尋找答案。

var oauth2Client = new OAuth2("CLIENT_ID", "CLIENT_SECRET", []), 
 
    google = require('googleapis'), 
 
    ytdapi = google.youtube('v3'); 
 

 
oauth2Client.setCredentials({ 
 
    refresh_token: "REFRESH_TOKEN" 
 
}); 
 

 
var params = { 
 
    auth: oauth2Client, 
 
    part: "snippet", 
 
    resource: { 
 
     snippet: { 
 
     channelId: "CHANNEL_ID", 
 
     videoId: "VIDEO_ID, 
 
     topLevelComment: { 
 
     snippet: { 
 
      textOriginal: "YOUR TEXT HERE " 
 
     } 
 
     } 
 
    } 
 
    } 
 
}; 
 

 

 
ytdapi.commentThreads.insert(params, function(err, data) { 
 
    if (err) { 
 
    console.log(err); 
 
    res.status(400).send("Error posting comment "); 
 
    } 
 
    else { 
 
    console.log(data); 
 
    res.status(200).send("Successfully posted comment "); 
 
    } 
 
});

+0

什麼是 「ytdapi」 在這裏? –

+1

@GopinathShiva我已經更新了示例以包含變量聲明。讓我知道你是否需要更多幫助。 – AboulEinein

相關問題