Created
October 21, 2024 08:21
-
-
Save dogterbox/fbf00b37ad89feeb6fa9937240f6c50f to your computer and use it in GitHub Desktop.
LINE Bot Notify
This file contains 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 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