Created
August 28, 2024 04:25
-
-
Save bhuiyanmobasshir94/bf3c0bbb8e492d15d78c5c0bb7b303b2 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 json | |
def lambda_handler(event, context): | |
# TODO implement | |
print(event) | |
print(context) | |
VERIFY_TOKEN = "ABCD" | |
http_method = event.get("requestContext", {}).get("http", {}).get("method") | |
if http_method == "GET": | |
query_params = event.get("queryStringParameters", {}) | |
verify_token = query_params.get("hub.verify_token") | |
challenge = query_params.get("hub.challenge") | |
if verify_token != VERIFY_TOKEN: | |
return {"statusCode": 403, "body": "Forbidden"} | |
return {"statusCode": 200, "body": challenge} | |
elif http_method == "POST": | |
body = json.loads(event.get("body", "{}")) | |
return {"statusCode": 200, "body": json.dumps({"status": "success"})} | |
else: | |
return {"statusCode": 405, "body": "Method Not Allowed"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment