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

$data = array(
    'messaging_product' => 'whatsapp',
    'to' => '51968097419',
    'type' => 'template',
    'template' => array(
        'name' => 'mensaje_de_prueba',
        'language' => array(
            'code' => 'es'
        )
    )
);

$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;
?>
