1. Go to this page and download the library: Download envoisms/envoisms-php 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/ */
envoisms / envoisms-php example snippets
nvoiSMS\Client;
$client = new Client(getenv('ENVOISMS_API_KEY'));
$response = $client->send([
'to' => '+212600000000',
'message' => 'Votre code de vérification est 492018',
'from' => 'MonBusiness', // validated Sender ID, or omit to use your default
]);
echo 'Message ID: ' . $response['id']; // poll it with getMessage(), match it in webhooks
// Reply to a customer who wrote to your number in the last 24 h
$response = $client->send([
'to' => '+212600000000',
'message' => 'Bonjour ! Votre commande #89240 a été expédiée.',
'channel' => 'whatsapp',
]);
// Start the conversation yourself: approved template, any time
$response = $client->send([
'to' => '+212600000000',
'message' => 'Votre commande #89240 a été expédiée.', // shown in your history; the template body is what goes out
'channel' => 'whatsapp',
'template' => ['name' => 'order_shipped', 'language' => 'fr', 'variables' => ['89240']],
]);
use EnvoiSMS\Client;
$rawBody = file_get_contents('php://input'); // raw request body, not the parsed array
$isValid = Client::verifyWebhookSignature(
$rawBody,
$_SERVER['HTTP_X_ENVOISMS_SIGNATURE'],
getenv('ENVOISMS_WEBHOOK_SECRET')
);