67
79

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PythonでLINEに通知を送る

Posted at

バッチなどで日々のKPIを自動で集計した内容をすぐ確認できるようにしてみる。今回はLINEへ通知する方法。とても簡単

1.まずは下記にアクセスし、ログインした上で通知を行いたいチャットに対してアクセストークンの発行を行う。

image

2.発行されたアクセストークンをメモして(1回しか表示されないらしいので注意。コピーし忘れたら一旦提携を解除してもう一度発行しなおせばOK)

3.以下のコードを追加

import requests

line_notify_token = 'アクセストークン'
line_notify_api = 'https://notify-api.line.me/api/notify'
message = '通知したい内容'


payload = {'message': message}
headers = {'Authorization': 'Bearer ' + line_notify_token}  # 発行したトークン
line_notify = requests.post(line_notify_api, data=payload, headers=headers)

67
79
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
67
79

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?