First, log in to the LINE Notify site and issue a token. https://notify-bot.line.me/ja/
・ Mac ・ Python
(1) Directory structure Save gazo.jpeg in images.
test
├test.py
└images
└gazo.img
(2) Describe test.py The code is as follows.
.py:test.py
#coding:UTF-8
import requests,os
#------When sending an image----------------------------
def main_gazo():
url = "https://notify-api.line.me/api/notify"
token = "*********************************"
headers = {"Authorization" : "Bearer "+ token}
message = 'Fortnite!'
payload = {"message" : message}
#Gazo in the images folder.jpg
files = {"imageFile":open('images/gazo.jpeg','rb')}
#rb reads the binary file
post = requests.post(url ,headers = headers ,params=payload,files=files)
#------When sending a message----------------------------
def main():
url = "https://notify-api.line.me/api/notify"
token = "*********************************"
headers = {"Authorization" : "Bearer "+ token}
message = 'Fortnite!'
payload = {"message" : message}
r = requests.post(url ,headers = headers ,params=payload)
if __name__ == '__main__':
main_gazo()#Send image main_gazo()Try to move (main for message)())
Recommended Posts