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 = 'XXXXXXXXXXXXXXXXXX' | |
const consumerSecret = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | |
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 main () { | |
// 本来投稿文を取得する機能を応用する | |
const tweetURL = TwitterClient.pickUpTweetInOrder() | |
// URLからTweetIdを取得する | |
const tweetId = TwitterClient.convertFromUrlToTweetId(tweetURL) | |
// RTを行う | |
client.retweet([tweetId]) | |
} | |
/** | |
* 認証を削除したい時はこれを実行する | |
*/ | |
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