Pythonとかでエラーなど何かを検知した時に自分宛に通知を送りたい時、誰しもがスマホにインストールしているLINEは通知先として有力な候補になると思います
LINE Notifyを使えば簡単に通知できるのですが、事前処理(登録)が必要なのでその手順をまとめてみました
アクセストークンを発行する
まずはLINEのサイトへ
https://notify-bot.line.me/ja/
ここから一気にトークン発行まで進めます
右上の”ログイン”のリンクを押下

メアドとパスワード or QRコードでログインを
※事前にスマホでメアドとパスワードの登録&ログイン許可の設定要

右上がアカウント名に変わったのを確認してアカウント名を押下
さらに小窓のマイページを押下

画面下部にある”トークンを発行する”を押下

トークン名を適当に入力して「1:1でLINE~」を押下
(グループも選べます)

“発行する”が活性化するので押下

ランダムな英数字のトークンが発行されるので控える

連携中サービスが追加されたことを確認

Pythonのサンプルプログラム
トークンを取得したものに置き換えるだけで自分へのLINE通知が可能になります
# -*- coding: utf-8 -*-
import requests
def line_notification(message):
line_notify_api = 'https://notify-api.line.me/api/notify'
line_notify_token = 'H0MxQj0i7vYlre5zIt0pMJ7hJLefaEWornnfqyWL8EH'
payload = {'message': message}
headers = {'Authorization': f'Bearer {line_notify_token}'}
_ = requests.post(line_notify_api, data=payload, headers=headers)
if __name__ == '__main__':
line_notification('テスト通知')
あとがき
自分のLINEに通知を送るための準備と簡単なソースでした
トークンとメッセージをPOSTするだけの簡単なお仕事でもちろんPython以外でも使えますので是非
コメント