Last active
March 11, 2023 14:40
-
-
Save jackrobotics/0c0b25edd2d6529593dd8250bf7ffb18 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python | |
# -*- coding: utf-8 -*- | |
def lineNotify(message): | |
payload = {'message':message} | |
return _lineNotify(payload) | |
def notifyFile(filename): | |
file = {'imageFile':open(filename,'rb')} | |
payload = {'message': 'test'} | |
return _lineNotify(payload,file) | |
def notifyPicture(url): | |
payload = {'message':" ",'imageThumbnail':url,'imageFullsize':url} | |
return _lineNotify(payload) | |
def notifySticker(stickerID,stickerPackageID): | |
payload = {'message':" ",'stickerPackageId':stickerPackageID,'stickerId':stickerID} | |
return _lineNotify(payload) | |
def _lineNotify(payload,file=None): | |
import requests | |
url = 'https://notify-api.line.me/api/notify' | |
token = '9IBnp37LVHj0a6W5HLq2dF7sqIjGyEVn2DQtpQq7wYv' #EDIT | |
headers = {'Authorization':'Bearer '+token} | |
return requests.post(url, headers=headers , data = payload, files=file) | |
# notifyFile('./logo.png') | |
lineNotify('ทดสอบภาษาไทย hello') | |
notifySticker(40,2) | |
notifyPicture("https://www.honey.co.th/wp-content/uploads/2017/03/cropped-logo_resize.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment