Send messages and images using LineNotify

Try sending Fortnite images and messages using LineNotify.

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

Send messages and images using LineNotify
Send and receive Flask images
Send messages to Skype and Chatwork in Python
Download images using requests
Send and receive Gmail via the Gmail API using Python
Collect images using icrawler
Collection and automation of erotic images using deep learning
Send experiment results (text and images) to slack with Python
[Go language] Collect and save Vtuber images using Twitter API
Save images using python3 requests
Categorize cat images using ChainerCV
Extract and package initrd images
When using if and when using while
This and that using reflect
Send email using Python's smtplib
Try using pytest-Overview and Samples-
Send using Python with Gmail
Try to recognize and distinguish Shanimas character images using YOLO v3
Aligning scanned images of animated video paper using OpenCV and Python