Skip to content

Instantly share code, notes, and snippets.

@armm29393
Last active May 8, 2024 02:54
Show Gist options
  • Select an option

  • Save armm29393/6dfc63bf318666909426ef02be778417 to your computer and use it in GitHub Desktop.

Select an option

Save armm29393/6dfc63bf318666909426ef02be778417 to your computer and use it in GitHub Desktop.
Python Line Notify
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