1. Go to this page and download the library: Download messente/messente-api-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/ */
messente / messente-api-php example snippets
Messente\Api\Api\OmnimessageApi;
use Messente\Api\Model\Omnimessage;
use Messente\Api\Configuration;
use Messente\Api\Model\WhatsApp;
use Messente\Api\Model\WhatsAppParameter;
use Messente\Api\Model\WhatsAppComponent;
use Messente\Api\Model\WhatsAppLanguage;
use Messente\Api\Model\WhatsAppTemplate;
// Configure HTTP basic authorization: basicAuth
$config = Configuration::getDefaultConfiguration()
->setUsername('<MESSENTE_API_USERNAME>')
->setPassword('<MESSENTE_API_PASSWORD>');
$apiInstance = new OmnimessageApi(
new GuzzleHttp\Client(),
$config
);
$omnimessage = new Omnimessage([
"to" => "<phone number in e.164 format>"
]);
$viber = new Viber(
["text" => "Hello Viber!", "sender" => "MyViberSender"]
);
$sms = new SMS(
["text" => "Hello SMS!", "sender" => "MySmsSender"]
);
$whatsAppParameters = [new WhatsAppParameter(['type' => 'text', 'text' => 'hello whatsapp'])];
$whatsAppComponent = new WhatsAppComponent(['type' => 'body', 'parameters' => $whatsAppParameters]);
$whatsAppLanguage = new WhatsAppLanguage(['code' => '<language_code>']);
$whatsAppTemplate = new WhatsAppTemplate(
[
'name'=> '<template_name>',
'language'=> $whatsAppLanguage,
'components' => [$whatsAppComponent]
]
);
$whatsapp = new WhatsApp(
[
'sender' => '<sender name (optional)>',
'template' => $whatsAppTemplate,
]
);
$omnimessage->setMessages([$whatsapp, $viber, $sms]);
try {
$result = $apiInstance->sendOmnimessage($omnimessage);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling sendOmnimessage: ', $e->getMessage(), PHP_EOL;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.