presents by IT Consulting 109

Slack – ユーザー一覧の取得

概要

Slackのユーザー一覧を取得する方法について記載。

slackで取得した投稿内容はユーザー情報がIDで表示されているため、そのままでは有効に活用できないケースがあります。

今回は、Slackで管理されているユーザーを取得して、変換する目的としてユーザーデータの取得と加工を行います。

 

手順

■トークンIDの取得
トークンIDの取得は以前紹介した『Slack – 投稿内容の取得』を参照
https://www.itc109.com/knowledge/slack/slack-get-message

 
 
■ユーザー一覧の取得

curl 'https://slack.com/api/users.list?token=[トークンID]&pretty=1'

 
 
■ユーザー一覧をファイルに出力

curl 'https://slack.com/api/users.list?token=[トークンID]&pretty=1' -o slack_user.dat

 
 
■ID,名前,表示名のみをCSVで出力

cat slack_user.dat | jq -c '.members[] | [.id,.name,.real_name]' | cut -c 2- | rev | cut -c 2- | rev > slack_user.csv
この記事を書いた人
名前:TRUE's。 千葉県育ち、神奈川県在住のIT系フリーエンジニア。 IT系のナレッジサイトを不定期で更新中。 フォトグラファー兼エンジニアとして日々勤しんでいる。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny