PHP code example of esolutions / ws

1. Go to this page and download the library: Download esolutions/ws library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

esolutions / ws example snippets


'ws' => [
    'url'   => env('WS_API_URL'),
    'token' => env('WS_API_TOKEN'),
],

use Esolutions\Ws\Service as WhatsApp;

$pdfContent = file_get_contents('/ruta/al/archivo.pdf');

$result = WhatsApp::sendPdf(
    base64Pdf: base64_encode($pdfContent),
    number: '51987654321',
    message: 'Adjunto su comprobante de pago',
    filename: 'factura_F001-001.pdf'
);

// → ['success' => true, 'messageId' => 'abc123']
// → ['success' => false, 'message' => 'Sesión no disponible']

$result = WhatsApp::sendText(
    sessionId: 'session-01',
    to: '51987654321',
    text: 'Su pedido fue confirmado. Gracias por su compra.'
);

$sessions = WhatsApp::getSessions();

// → [
//     'success' => true,
//     'data' => [
//         ['id' => 'session-01', 'status' => 'connected'],
//         ['id' => 'session-02', 'status' => 'disconnected'],
//     ]
// ]

$status = WhatsApp::getSessionStatus('session-01');

// → ['success' => true, 'data' => ['status' => 'connected']]

$status = WhatsApp::getMessageStatus('abc123');

// → ['success' => true, 'data' => ['status' => 'delivered']]