This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// スプレッドシート A列にコメント・B列に投稿する画像のURLをセットで記載 | |
// 画像のURLはアクセスできればなんでも良い。たとえば http://qiita.com/arribux/items/0394968fa318d9309d33 | |
// IFTTTには Maker Webhooks -> twitter で連携する。開発用トークンは必要なし | |
function myFunction() { | |
var spreadsheet = SpreadsheetApp.getActive(); | |
var sheet = spreadsheet.getSheets()[0]; | |
var maxRow = sheet.getDataRange().getLastRow(); // 最終行の番号 | |
var index = Math.floor(Math.random() * maxRow) + 1; // ランダムな番号を取得。indexは1から開始 | |
var comment = sheet.getRange(index, 1).getValue(); // A列からコメントを取得 | |
var figurl = sheet.getRange(index, 2).getValue(); // B列から画像のURLを選択 |
NewerOlder