Access Slack files from a slack bot

前端 未结 4 1263
小蘑菇
小蘑菇 2021-02-18 23:28

I need a slack bot that\'s able to receive and save files send from slack chatrooms.

The problem is: slack doesn\'t send file contents, but an array of links pointing to

4条回答
  •  暖寄归人
    2021-02-19 00:02

    You can access private URLs from your bot by providing an access token in the HTTP header when you are doing you CURL request.

    Your token needs to have the scope files.read in order to get access.

    The format is:

    Authorization: Bearer A_VALID_TOKEN
    

    Replace A_VALID_TOKEN with your slack access token.

    I just tested it with a simple PHP script to retrieve a file by its "url_private" and it works nicely.

    Source: Slack API documententation / file object / Authentication

提交回复
热议问题