<?php
$url = 'https://graph.facebook.com/v18.0/210011768871570/messages';
$accessToken = 'EAAcHqa6F5ZBsBO7HVUqt2qqkBiPRcbjtZASP7xFb275MoKjM4zFrOzOFeq3VuQcDwgYEqz6jy8XaY0ll3kZAew0NIx86qG1ZAUcm8WozezmSSArmdmvllLebhXw6EefCWlM7cKzyUHYCAyGoc54kdsrwWIVX5jmIxeHCbWGzcyjA5WKS40oE8Uug5EWGghV7pjPJnSOPKswx4j9BHqeW';

$data = array(
    "messaging_product" => "whatsapp",
    "recipient_type" => "individual",
    "to" => "51968097419",
    "type" => "interactive",
    "interactive" => array(
        "type" => "button",
        "body" => array(
            "text" => "¡Hola! Este es un mensaje de prueba enviado desde Node.js a través de la API de WhatsApp.: http://sistema.maxillaris.pe/auth/signin"
        ),
        "header" => array(
            "type" => "image",
            "image" => array(
                "id" => "1380026912704312"
            )
        ),
        "footer" => array(
            "text" => "¿No te interesa? Toca 'Detener promociones'"
        ),
        "action" => array(
            "buttons" => array(
                array(
                    "type" => "reply",
                    "reply" => array(
                        "id" => "<UNIQUE_BUTTON_ID_1>",
                        "title" => "Detener promociones"
                    )
                )
            )
        )
    )
);

$data_string = json_encode($data);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Authorization: Bearer ' . $accessToken,
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string))
);

$result = curl_exec($ch);
curl_close($ch);

echo $result;
?>
