File size: 559 Bytes
0d6b0e6
6915dbd
 
 
0d6b0e6
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from fastapi import FastAPI, Query, HTTPException

app = FastAPI()

VERIFY_TOKEN = "lintasmediadanawa"  # Replace with your actual verify token


@app.get("/webhooks")
async def handle_webhook(
    hub_mode: str = Query(..., alias="hub.mode"),
    hub_challenge: int = Query(..., alias="hub.challenge"),
    hub_verify_token: str = Query(..., alias="hub.verify_token")
):
    if hub_mode == "subscribe" and hub_verify_token == VERIFY_TOKEN:
        return int(hub_challenge)
    else:
        raise HTTPException(status_code=403, detail="Verification failed")