Quantcast
Viewing all articles
Browse latest Browse all 8916

Node.jsでGoogle Slides内のテキストの書き換え

Google Slides APIをNode.jsから触ってみてます。

の記事の続きです。

batchUpdate()で更新

presentations.batchUpdateでどうやら更新ができそうです。

presentations.batchUpdate()の

presentations.batchUpdate()の使い方がいまいち分からなかったけど、stackoverflowの投稿を参考に

presentationId:プレゼンテーションIDを指定,resource:{requests:{//ここにリクエストする内容を入れる}}

みたいな使い方というのが分かりました。

app.js
省略functionlistSlides(auth){constslides=google.slides({version:'v1',auth});slides.presentations.batchUpdate({presentationId:presentationId,resource:{requests:{replaceAllText:{containsText:{text:"Node.js"//置き換え前のテキスト},replaceText:"Hoge"//置き換え後のテキスト}}}},(err,res)=>{if(err)returnconsole.log('The API returned an error: '+err);console.log(res.data);});}

Node.jsというテキストをHogeに書き換えます。

実行

Image may be NSFW.
Clik here to view.

こんな感じで書き換えができました。

所感

今回はreplaceAllTextというリクエストをしましたが、他のリクエスト方法もあるので試していきたいです。

/v1/presentations/request


Viewing all articles
Browse latest Browse all 8916

Trending Articles