This file contains hidden or 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
'use strict'; | |
const consumerKey = 'XXXXXXXXXXXXXXXXXXXXXXXXX' | |
const consumerSecret = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | |
const consumerKeyB = 'YYYYYYYYYYYYYYYYYYYYYYYYY' | |
const consumerSecretB = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY' | |
const consumerKeyC = 'ZZZZZZZZZZZZZZZZZZZZZZZZZ' | |
const consumerSecretC = 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ' |
This file contains hidden or 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
'use strict'; | |
const consumerKey = 'XXXXXXXXXXXXXXXXXXXX' | |
const consumerSecret = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | |
const client = TwitterClient.getInstance(consumerKey, consumerSecret) | |
/** | |
* ①Twitterで作ったアプリに登録するための callbackUrl を取得する | |
* 実行後 『表示』→『ログ』でURLを確認してTwitterアプリに登録 |
This file contains hidden or 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
/** | |
* ③最新のツイートをリツイートする | |
*/ | |
function retweetLatest () { | |
// 最新のツイートのツイートIDを取得する(バージョン25以前) | |
// const accountName = 'belltreeszk' // 対象のアカウントの @~~~~ の部分を記入 | |
// const includeRT = false // RTを含むか(他のユーザーのツイートのRTも再度RTします) | |
// const retweetCount = 5 // 直近何件のツイートをRTするか | |
// const tweetIds = client.pickupTweetsLatest(accountName, includeRT, retweetCount); | |
This file contains hidden or 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
/** | |
* ③シートにまとめているツイートをリツイートする | |
*/ | |
function retweetSpreadSheetList () { | |
// 「シート1」に記載されたツイートIDを取得する | |
// シートの参考例: https://docs.google.com/spreadsheets/d/1Xr1G4FTglcE68j7eylcrwJgQtzfN0AB3K7EKZMIFQ8I/edit#gid=1056960065 | |
const tweetIds = TwitterClient.pickupAllTweetLink('シート1'); | |
// 受け取ったツイートIDのツイートをすべてリツイートする | |
client.retweet(tweetIds) |
This file contains hidden or 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
'use strict'; | |
const consumerKey = 'XXXXXXXXXXXXXXXXXXXXXX' | |
const consumerSecret = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | |
const client = TwitterClient.getInstance(consumerKey, consumerSecret) | |
/** | |
* ①Twitterで作ったアプリに登録するための callbackUrl を取得する | |
* 実行後 『表示』→『ログ』でURLを確認してTwitterアプリに登録 |
This file contains hidden or 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
// スプレッドシートのシートのデータを取得する(下記画像の赤、青まで) | |
const sheetName = 'シート1' | |
const sheetData = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName); | |
// 全てのセルのデータを取得する(下記画像の緑、オレンジまで) | |
const startRow = 1 | |
const startCol = 1 | |
const endRow = sheetData.getLastRow() | |
const endCol = sheetData.getLastColumn() | |
const cells = sheetData.getRange(startRow, startCol, endRow, endCol).getValues(); |
This file contains hidden or 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
const startRow = 1 | |
const startCol = 1 | |
const endRow = sheetData.getLastRow() // 最終行 | |
const endCol = sheetData.getLastColumn() // 最終列 | |
// 悪い例 | |
for (let i = startRow; i <= endRow; i++) { | |
// 行数分getRangeとgetValueが実行される | |
const cell = sheetData.getRange(i, startCol, 1, endCol).getValue(); | |
// 実行する |
This file contains hidden or 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
const sheetData = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName); | |
const titleRow = 1; // 『投稿内容』とか書いている部分の行数 | |
const startRow = 1 + titleRow; // 1行目は『投稿内容』とか書いているので2行目から | |
const startCol = 1; | |
const endRow = sheetData.getLastRow() - titleRow; // 最後の行まで(2行目から始まっているので-1している) | |
const endCol = 2; // 『投稿回数』の列までなので2列目まで | |
// ① 投稿を一括で取得する | |
const cells = sheetData.getRange(startRow, startCol, endRow, endCol).getValues(); | |
This file contains hidden or 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
function main () { | |
// 本来投稿文を取得する機能を応用する | |
const tweetURL = TwitterClient.pickUpTweetInOrder() | |
// URLからTweetIdを取得する | |
const tweetId = TwitterClient.convertFromUrlToTweetId(tweetURL) | |
// RTを行う | |
client.retweet([tweetId]) | |
} |
This file contains hidden or 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
/** | |
いいね or RT 機能 | |
① 検索ワードをスプレッドシートから取得する | |
② 検索ワードをTwitterで検索する(たくさん取れてしまうので「直近10分間」の検索を10分毎に行う) | |
③ ツイートに いいね or RT をする | |
④ 他に検索ワードがあれば②に戻る | |
*/ | |
function main () { | |
// ① 検索ワードをスプレッドシートから取得する | |
var searchWords = pickUpSearchWords(); |