PHP code example of hexxondiv / whatsapp
1. Go to this page and download the library: Download hexxondiv/whatsapp 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/ */
hexxondiv / whatsapp example snippets
re_once('ultramsg.class.php'); // if you download ultramsg.class.php
$ultramsg_token="tof7lsdJasdloaa57e"; // Ultramsg.com token
$instance_id="instance1150"; // Ultramsg.com instance id
$client = new Hexxondiv\WhatsAppApi($ultramsg_token,$instance_id);
$to="put_your_mobile_number_here";
$body="Hello world";
$referenceId="WA12348765";
$api=$client->sendChatMessage($to,$body,$referenceId);
print_r($api);
$to="put_your_mobile_number_here";
$body="Hello world";
$priority=10;
$referenceId="WA-1232948374";
$api=$client->sendChatMessage($to,$body,$priority,$referenceId);
print_r($api);
$to="put_your_mobile_number_here";
$caption="image Caption";
$image="https://file-example.s3-accelerate.amazonaws.com/images/test.jpg";
$referenceId="WA-1232948374";
$api=$client->sendImageMessage($to,$image,$caption,$referenceId);
print_r($api);
$to="put_your_mobile_number_here";
$audio="https://file-example.s3-accelerate.amazonaws.com/audio/2.mp3";
$caption="Document Caption";
$api=$client->sendAudioMessage($to,$audio,$caption);
print_r($api);
$to="put_your_mobile_number_here";
$audio="https://file-example.s3-accelerate.amazonaws.com/voice/oog_example.ogg";
$api=$client->sendVoiceMessage($to,$audio);
print_r($api);
$to="put_your_mobile_number_here";
$video="https://file-example.s3-accelerate.amazonaws.com/video/test.mp4";
$caption="Video Caption"
$api=$client->sendVideoMessage($to,$video,$caption);
print_r($api);
$to="put_your_mobile_number_here";
$link="https://ultramsg.com";
$caption="link Caption"
$api=$client->sendLinkMessage($to,$link,$caption);
print_r($api);
$to="put_your_mobile_number_here";
$contact="[email protected] ";
$api=$client->sendContactMessage($to,$contact);
print_r($api);
$to="put_your_mobile_number_here";
$address="ABC company \n Sixth floor , office 38";
$lat="25.197197";
$lng="55.2721877";
$api=$client->sendLocationMessage($to,$address,$lat,$lng);
print_r($api);
$to="put_your_mobile_number_here";
$vcard="BEGIN:VCARD
VERSION:3.0
N:lastname;firstname
FN:firstname lastname
TEL;TYPE=CELL;waid=14000000001:14000000002
NICKNAME:nickname
BDAY:01.01.1987
X-GENDER:M
NOTE:note
ADR;TYPE=home
ADR;TYPE=work
END:VCARD";
$vcard = preg_replace("/[\n\r]/", "\n", $vcard);
$api=$client->sendVcardMessage($to,$vcard);
print_r($api);
$page=1;
$limit=100;
$status="all";
$sort="asc";
$api=$client->getMessages($page,$limit,$status,$sort);
print_r($api);
$api=$client->getMessageStatistics();
print_r($api);
$api=$client->getInstanceStatus();
print_r($api);
header('Content-Type: image/png');
$api=$client->getInstanceQr();
print_r($api);
$api=$client->getInstanceQrCode();
print_r($api);
header('Content-Type: image/png');
$api=$client->getInstanceScreenshot();
print_r($api);
$api=$client->getInstanceScreenshot("base64");
print_r($api);
$api=$client->getInstanceMe();
print_r($api);
$api=$client->getInstanceSettings();
print_r($api);
$api=$client->sendInstanceTakeover();
print_r($api);
$api=$client->sendInstanceLogout();
print_r($api);
$api=$client->sendInstanceRestart();
print_r($api);
$sendDelay=1;
$webhook_url="";
$webhook_message_received=false;
$webhook_message_create=false;
$webhook_message_ack=false;
$api=$client->sendInstanceSettings($sendDelay,$webhook_url,$webhook_message_received,$webhook_message_create,$webhook_message_ack);
print_r($api);
composer
php
$to="put_your_mobile_number_here";
$filename="image Caption";
$document="https://file-example.s3-accelerate.amazonaws.com/documents/cv.pdf";
$referenceId="34564563563";
$caption="Document Caption";
$api=$client->sendDocumentMessage($to,$filename,$document,$caption,$referenceId);
print_r($api);