Google Slides APIをNode.jsから触ってみてます。
の記事の続きです。
batchUpdate()で更新
presentations.batchUpdateでどうやら更新ができそうです。
presentations.batchUpdate()の
presentations.batchUpdate()
の使い方がいまいち分からなかったけど、stackoverflowの投稿を参考に
presentationId: プレゼンテーションIDを指定,
resource: {
requests: {
//ここにリクエストする内容を入れる
}
}
みたいな使い方というのが分かりました。
app.js
省略
function listSlides(auth) {
const slides = google.slides({version: 'v1', auth});
slides.presentations.batchUpdate({
presentationId: presentationId,
resource: {
requests: {
replaceAllText: {
containsText: {
text: "Node.js" //置き換え前のテキスト
},
replaceText: "Hoge" //置き換え後のテキスト
}
}
}
}, (err, res) => {
if (err) return console.log('The API returned an error: ' + err);
console.log(res.data);
});
}
Node.jsというテキストをHogeに書き換えます。
実行
こんな感じで書き換えができました。
所感
今回はreplaceAllText
というリクエストをしましたが、他のリクエスト方法もあるので試していきたいです。