Skip to content

Instantly share code, notes, and snippets.

@dogterbox
Created October 21, 2024 08:21
Show Gist options
  • Save dogterbox/fbf00b37ad89feeb6fa9937240f6c50f to your computer and use it in GitHub Desktop.
Save dogterbox/fbf00b37ad89feeb6fa9937240f6c50f to your computer and use it in GitHub Desktop.
LINE Bot Notify
import requests
# generate token from https://notify-bot.line.me/my/
TOKEN = "YOUR_LINE_NOTIFY_TOKEN"
def send_line_notify(message):
url = "https://notify-api.line.me/api/notify"
headers = {
"Authorization": f"Bearer {TOKEN}"
}
data = {
"message": message
}
response = requests.post(url, headers=headers, data=data)
if response.status_code == 200:
print("Notification sent successfully!")
else:
print(f"Failed to send notification. Status code: {response.status_code}")
if __name__ == "__main__":
message = 'Hello! This is a test notification from Python.'
send_line_notify(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment