Skip to content

Instantly share code, notes, and snippets.

@KoheiKanagu
Last active August 29, 2016 11:54
Show Gist options
  • Save KoheiKanagu/adcb98c70ba6756cabb0616208591539 to your computer and use it in GitHub Desktop.
Save KoheiKanagu/adcb98c70ba6756cabb0616208591539 to your computer and use it in GitHub Desktop.
ParseのAPIを叩くいろいろ
#Slackにアップロードされたファイルを一括削除
token="__YOUR_API_KEY__"
timeStamp=1451573999 #2015年12月31日23時59分
fileCount=`curl -s "https://slack.com/api/files.list?token=${token}&ts_to=${timeStamp}&pretty=1&count=${fileCount}" | jq .paging.total`
echo $fileCount 件
files=`curl "https://slack.com/api/files.list?token=${token}&ts_to=${timeStamp}&pretty=1&count=${fileCount}"| jq ".files[].id" | sed -e "s/\"//g"`
for var in $files
do
echo $var
curl -s -S "https://slack.com/api/files.delete?token=${token}&file=$var&pretty=1"
done
#ユーザ毎のファイル数をカウント
token="__YOUR_API_KEY__"
users=`curl "https://slack.com/api/users.list?token=${token}&pretty=1" | jq .members[].id | sed -e "s/\"//g"`
sum=0
for var in $users
do
count=`curl -s -S "https://slack.com/api/files.list?token=${token}&user=${var}&count=1000&pretty=1" | jq .paging.total`
echo $var : $count
sum=`expr ${count} + ${sum}`
done
echo Sum: $sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment