import logging import httpx logger = logging.getLogger(__name__) MESSENGER_API_BASE = "https://graph.facebook.com/v22.0" class MessengerPrivateReplyAPI: def __init__(self, access_token: str): self._access_token = access_token async def send_private_reply( self, comment_id: str, message: str, ) -> dict | None: url = f"{MESSENGER_API_BASE}/{comment_id}/private_replies" body = {"message": message} try: async with httpx.AsyncClient(timeout=httpx.Timeout(30.0)) as client: resp = await client.post( url, params={"access_token": self._access_token}, json=body, ) if resp.status_code == 200: return resp.json() logger.error(f"messenger private_reply failed: {resp.status_code} {resp.text}") return None except Exception: logger.exception("messenger private_reply error") return None