Last active
May 8, 2024 02:54
-
-
Save armm29393/6dfc63bf318666909426ef02be778417 to your computer and use it in GitHub Desktop.
Python Line Notify
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
| import os | |
| import requests | |
| def linenotify(message, imagePath=None, stickerPackageId=None, stickerId=None, tk=''): | |
| url = 'https://notify-api.line.me/api/notify' | |
| token = os.getenv('LINE_NOTIFY_TOKEN') or (tk or None) | |
| if token is None: | |
| print('LINE_NOTIFY_TOKEN is required!') | |
| return False | |
| header = {'Authorization': f'Bearer {token}'} | |
| data = { | |
| 'message': f'{message}', | |
| 'stickerPackageId': stickerPackageId, | |
| 'stickerId': stickerId, | |
| } | |
| file = {'imageFile': open(imagePath,'rb')} if (imagePath) else None | |
| r = requests.post(url, headers=header, data=data, files=file) | |
| return r.json() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment