Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
8
Help us understand the problem. What is going on with this article?
@satoshin2071

slackのアップロード用APIをpythonから叩いて画像アップロード

More than 5 years have passed since last update.

前提
アクセストークンは手動、もしくはmechanize等を利用して取得済みとする。
通信ライブラリはrequestsを使用する

with open("FILE_PATH",'rb') as f:
    param = {'token':access_token, 'channels':CHANNEL_ID,'title':'タイトル'}
    r = requests.post("https://slack.com/api/files.upload", params=param,files={'file':f})

CHANNEL_IDは各チャンネルのタイトルクリックしてAdd a servive integration... に飛ぶとURLパラメータにidがあるのでそれを利用する。

参考 https://github.com/os/slacker/blob/master/slacker/__init__.py

8
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
satoshin2071
Software Developer 💻 iOS / ObjC / Swift / Ruby 🐥 Flutter / AWS 😎 焚き火 / Mixcloud / TIDAL
zozotech
70億人のファッションを技術の力で変えていく

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
8
Help us understand the problem. What is going on with this article?