Last active
September 8, 2018 07:08
-
-
Save sorashido/342ca8a2626c5a470dfa0b2514d7b624 to your computer and use it in GitHub Desktop.
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
/* スコープを与える */ | |
var SlackDelFileApp = {} | |
/* SLACKのTOKENを読み込み */ | |
SlackDelFileApp.SLACK_ACCESS_TOKEN = PropertiesService.getScriptProperties().getProperty('SLACK_ACCESS_TOKEN');// slackで発行したTOKENをGASの環境変数に設定 | |
/* soundTricker/SlackApp を使うよりurlからAPI叩いたほうが早いらしいので */ | |
SlackDelFileApp.execute = function(method, params){ | |
if (params === undefined ) params = {'token' : SlackDelFileApp.SLACK_ACCESS_TOKEN}; | |
var options = { | |
'method': 'POST', | |
'payload': params | |
} | |
var res = UrlFetchApp.fetch('https://slack.com/api/' + method, options); | |
return JSON.parse(res.getContentText()); | |
} | |
/* ファイルのリスト取得 */ // unused | |
SlackDelFileApp.getFilesList = function(params){ | |
params.token = SlackDelFileApp.SLACK_ACCESS_TOKEN; | |
return this.execute('files.list', params); | |
} | |
function myFunction() { | |
var params = { | |
'token': SlackDelFileApp.SLACK_ACCESS_TOKEN, | |
} | |
var allfiles = SlackDelFileApp.getFilesList(params) | |
allfiles['files'].forEach(function(file) { | |
Logger.log(file['name']) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment