PHP code example of kolinalabs / naty-whatsapp-sdk
1. Go to this page and download the library: Download kolinalabs/naty-whatsapp-sdk 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/ */
kolinalabs / naty-whatsapp-sdk example snippets
use KolinaLabs\NatyApi;
$naty = new NatyApi('<your-naty-api-token>');
// Get whatsapp numbers with status
$whatsapps = $naty->whatsapps();
// Get specific whatsapp (eg: $whatsapps[0])
$whatsapp = current($whatsapps);
if (!$whatsapp) {
die('No connection returned.');
}
if(!$whatsapp->isConnected()) {
$status = $naty->connect($whatsapp);
}
$messages = [
[
'number' => '<whatsapp-number-here>',
'name' => '<your contact name>',
'body' => "Your custom message *Hello* 😎!\n" .
"Text with line breaks is also *accepted*:\n\n" .
"👍 *Instagram*: https://www.instagram.com/kolina.labs \n" .
"👎 *Website*: https://kolinalabs.com",
// 'mediaKey' => $mediaKey,
// 'mediaType' => 'image'
],
//... more messages here
];
// Send messages - Method 1
$result = $naty->messages($whatsapp, $messages);
// Send messages - Method 2
$result = $whatsapp->send($messages);