![Enviar mensajes con Api Oficial de WhatsApp en PHP 1 ENVIO DE WHATSAPP API WA PHP](https://www.programadornovato.com/wp-content/uploads/2023/01/ENVIO-DE-WHATSAPP-API-WA-PHP-640x360.png)
Enviar mensajes con Api Oficial de WhatsApp en PHP
En este tutorial aprenderemos a Enviar mensajes con Api Oficial de WhatsApp en PHP, solo debemos seguir estos pasos:
Creamos una app en Facebook
![Enviar mensajes con Api Oficial de WhatsApp en PHP 2 Enviar mensajes con Api Oficial de WhatsApp en PHP](https://www.programadornovato.com/wp-content/uploads/2023/01/image-51.png)
O podemos aceder a este link Todas las apps – Meta for Developers (facebook.com)
![Enviar mensajes con Api Oficial de WhatsApp en PHP 3 image 31](https://www.programadornovato.com/wp-content/uploads/2023/01/image-31-1024x361.png)
![Enviar mensajes con Api Oficial de WhatsApp en PHP 4 image 32](https://www.programadornovato.com/wp-content/uploads/2023/01/image-32.png)
![Enviar mensajes con Api Oficial de WhatsApp en PHP 5 image 33](https://www.programadornovato.com/wp-content/uploads/2023/01/image-33.png)
![Enviar mensajes con Api Oficial de WhatsApp en PHP 6 image 34](https://www.programadornovato.com/wp-content/uploads/2023/01/image-34-1024x592.png)
![Enviar mensajes con Api Oficial de WhatsApp en PHP 7 image 35](https://www.programadornovato.com/wp-content/uploads/2023/01/image-35-1024x699.png)
Configuramos el Api de WhatsApp
![Enviar mensajes con Api Oficial de WhatsApp en PHP 8 image 36](https://www.programadornovato.com/wp-content/uploads/2023/01/image-36-1024x671.png)
![Enviar mensajes con Api Oficial de WhatsApp en PHP 9 image 37](https://www.programadornovato.com/wp-content/uploads/2023/01/image-37-1024x673.png)
![Enviar mensajes con Api Oficial de WhatsApp en PHP 10 image 38](https://www.programadornovato.com/wp-content/uploads/2023/01/image-38-1024x678.png)
![Enviar mensajes con Api Oficial de WhatsApp en PHP 11 image 49](https://www.programadornovato.com/wp-content/uploads/2023/01/image-49-1024x845.png)
![Enviar mensajes con Api Oficial de WhatsApp en PHP 12 image 39](https://www.programadornovato.com/wp-content/uploads/2023/01/image-39-1024x748.png)
![Enviar mensajes con Api Oficial de WhatsApp en PHP 13 image 40](https://www.programadornovato.com/wp-content/uploads/2023/01/image-40-1024x830.png)
Enviar mensajes desde postman
![Enviar mensajes con Api Oficial de WhatsApp en PHP 14 image 53](https://www.programadornovato.com/wp-content/uploads/2023/01/image-53.png)
Enviar mensajes con Api Oficial de WhatsApp en PHP
![Enviar mensajes con Api Oficial de WhatsApp en PHP 15 image 58](https://www.programadornovato.com/wp-content/uploads/2023/01/image-58-1024x243.png)
![Enviar mensajes con Api Oficial de WhatsApp en PHP 16 image 59](https://www.programadornovato.com/wp-content/uploads/2023/01/image-59-1024x564.png)
<?php //TOKEN QUE NOS DA FACEBOOK $token = 'EAAIW7rNPtRsBAJ08gWP87RgwK03xZABkSWs6YYbXhcohaiCfA4DcOi3LPVnjz1Xpsycy8FZASv6Ny05tGCqds9HQI7r6dZAx5ne4ONgMRKZCQpFML1OZAiBF1DanvG7xo0We1N7IxW7C4ZBBfrnz4bi4ZCfl6zrru5ZB7HBVMZB1v5zKyCFjBQzZAZAuGTo48K8xDN8ZAHimIOHktQZDZD'; //NUESTRO TELEFONO $telefono = '521234567891'; //URL A DONDE SE MANDARA EL MENSAJE $url = 'https://graph.facebook.com/v15.0/105233795800723/messages'; //CONFIGURACION DEL MENSAJE $mensaje = '' . '{' . '"messaging_product": "whatsapp", ' . '"to": "'.$telefono.'", ' . '"type": "template", ' . '"template": ' . '{' . ' "name": "hello_world",' . ' "language":{ "code": "en_US" } ' . '} ' . '}'; //DECLARAMOS LAS CABECERAS $header = array("Authorization: Bearer " . $token, "Content-Type: application/json",); //INICIAMOS EL CURL $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POSTFIELDS, $mensaje); curl_setopt($curl, CURLOPT_HTTPHEADER, $header); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); //OBTENEMOS LA RESPUESTA DEL ENVIO DE INFORMACION $response = json_decode(curl_exec($curl), true); //IMPRIMIMOS LA RESPUESTA print_r($response); //OBTENEMOS EL CODIGO DE LA RESPUESTA $status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE); //CERRAMOS EL CURL curl_close($curl); ?>