Created
January 28, 2020 17:51
-
-
Save smd877/ed9a1e6be46a52246024bc72819a627c to your computer and use it in GitHub Desktop.
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 json | |
import urllib.request, urllib.parse | |
URL = 'https://api.line.me/v2/bot/message/push' | |
def lambda_handler(event, context): | |
to = event['to'] if 'to' in event.keys() else os.environ['SEND_TO'] | |
token = event['token'] if 'token' in event.keys() else os.environ['CHANNEL_TOKEN'] | |
headers = { | |
'Content-Type': 'application/json', | |
'Authorization': 'Bearer ' + token | |
} | |
body = { | |
'to': to, | |
'messages': event['messages'] | |
} | |
req = urllib.request.Request(URL, data=json.dumps(body).encode("utf-8"),headers=headers,method='POST') | |
urllib.request.urlopen(req) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment