Skip to content

Instantly share code, notes, and snippets.

@stepw66
Forked from jackrobotics/lineNotify.py
Created July 25, 2019 21:24
Show Gist options
  • Save stepw66/5cca3b0dcaa37793172cb9ef79421d73 to your computer and use it in GitHub Desktop.
Save stepw66/5cca3b0dcaa37793172cb9ef79421d73 to your computer and use it in GitHub Desktop.

Revisions

  1. @jackrobotics jackrobotics revised this gist Dec 17, 2018. 1 changed file with 21 additions and 15 deletions.
    36 changes: 21 additions & 15 deletions lineNotify.py
    Original file line number Diff line number Diff line change
    @@ -2,24 +2,30 @@
    # -*- coding: utf-8 -*-

    def lineNotify(message):
    payload = {'message':message}
    return _lineNotify(payload)
    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)
    payload = {'message':" ",'imageThumbnail':url,'imageFullsize':url}
    return _lineNotify(payload)

    def notifySticker(stickerID,stickerPackageID):
    payload = {'message':" ",'stickerPackageId':stickerPackageID,'stickerId':stickerID}
    return _lineNotify(payload)
    payload = {'message':" ",'stickerPackageId':stickerPackageID,'stickerId':stickerID}
    return _lineNotify(payload)

    def _lineNotify(payload):
    import requests
    url = 'https://notify-api.line.me/api/notify'
    token = '9IBnp37LVHj0a6W5HLq2dF7sqIjGyEVn2DQtpQq7wYv' #EDIT
    headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer '+token}
    return requests.post(url, headers=headers , data = 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)

    print lineNotify('ทดสอบภาษาไทย hello')
    print notifySticker(40,2)
    print notifyPicture("https://www.honey.co.th/wp-content/uploads/2017/03/cropped-logo_resize.png")
    # notifyFile('./logo.png')
    lineNotify('ทดสอบภาษาไทย hello')
    notifySticker(40,2)
    notifyPicture("https://www.honey.co.th/wp-content/uploads/2017/03/cropped-logo_resize.png")
  2. @jackrobotics jackrobotics created this gist May 30, 2018.
    25 changes: 25 additions & 0 deletions lineNotify.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    #!/usr/local/bin/python
    # -*- coding: utf-8 -*-

    def lineNotify(message):
    payload = {'message':message}
    return _lineNotify(payload)

    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):
    import requests
    url = 'https://notify-api.line.me/api/notify'
    token = '9IBnp37LVHj0a6W5HLq2dF7sqIjGyEVn2DQtpQq7wYv' #EDIT
    headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer '+token}
    return requests.post(url, headers=headers , data = payload)

    print lineNotify('ทดสอบภาษาไทย hello')
    print notifySticker(40,2)
    print notifyPicture("https://www.honey.co.th/wp-content/uploads/2017/03/cropped-logo_resize.png")