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
'use strict'; | |
const consumerKey = 'CONSUMER_KEY' | |
const consumerSecret = 'CONSUMER_SECRET' | |
const client = TwitterClient.getInstance(consumerKey, consumerSecret) | |
/** | |
* ①Twitterで作ったアプリに登録するための callbackUrl を取得する | |
* 実行後 『表示』→『ログ』でURLを確認してTwitterアプリに登録 | |
*/ | |
function getCallbackUrl() { | |
Logger.log('以下のURLをTwitterアプリのCallbackURLに登録'); | |
Logger.log(client.getCallbackUrl()); | |
} | |
/** | |
* ②認証を実行する | |
* 実行後『表示』→『ログ』で表示されたURLに移動 | |
*/ | |
function authorize () { | |
client.authorize() | |
} | |
/** | |
* ③ 画像つきで投稿する | |
*/ | |
function postTweetWithMedia () { | |
// https://docs.google.com/spreadsheets/d/1Xr1G4FTglcE68j7eylcrwJgQtzfN0AB3K7EKZMIFQ8I/edit#gid=945036492 | |
// ↑のシートの形式を元にツイートをランダムで選び画像つき投稿をする | |
const postData = TwitterClient.pickUpTweetDataRandom(); | |
client.postTweetWithDriveData(postData); | |
} | |
/** | |
* 認証を削除したい時はこれを実行する | |
*/ | |
function reset () { | |
client.reset() | |
} | |
/** | |
* authorizeでTwitterでの認証後に実行される処理 | |
* ※手動で実行はしません | |
*/ | |
function authCallback (request) { | |
return client.authCallback(request) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment