Help us understand the problem. What is going on with this article?

PythonからLINE NotifyでLINEにメッセージを送る

More than 1 year has passed since last update.

LINE Notifyとは?

LINEが提供するAPIで、システムからメッセージを簡単に送ることができます。
利用にあたっては、事前にトークルームのアクセストークンを発行する必要があります。

詳細は、前回の「Google Apps ScriptからLine NotifyでLINEにメッセージを送る」をご覧ください。

今回は、Python3からメッセージを送る方法になります。
requestsライブラリを使って、画像付きのメッセージを送るサンプルになります。

line_nofity.py
#coding:UTF-8
import requests

def main():
    url = "https://notify-api.line.me/api/notify"
    token = #ここにアクセストークンを入力します。
    headers = {"Authorization" : "Bearer "+ token}

    message =  'ここにメッセージを入れます'
    payload = {"message" :  message}
    files = {"imageFile": open("test.jpg", "rb")} #バイナリで画像ファイルを開きます。対応している形式はPNG/JPEGです。

    r = requests.post(url ,headers = headers ,params=payload, files=files)

if __name__ == '__main__':
    main()

参考URL

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
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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