Recommend this page to a friend! |
Download |
Info | Example | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 124 | All time: 9,456 This week: 40 |
Version | License | PHP version | Categories | |||
whatsapp-php-sdk 1.0.0 | Custom (specified... | 5 | PHP 5, Web services, Chat |
Description | Author | ||||||||
This package can send messages to WhatsApp users using Ultramsg API. |
|
Lightweight PHP library for WhatsApp API to send the whatsappp messages in PHP provided by Ultramsg.com
Just download ultramsg.class.php or use Composer:
composer require ultramsg/whatsapp-php-sdk
<?php
require_once ('vendor/autoload.php'); // if you use Composer
//require_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 UltraMsg\WhatsAppApi($ultramsg_token,$instance_id);
$to="put_your_mobile_number_here";
$body="Hello world";
$api=$client->sendChatMessage($to,$body);
print_r($api);
> NOTE: you need replace instance_id and token with yours in ultramsg.com account if you don't have account create one from here
You can use it to create a professional queue for messages, The Messages with less priority value are sent first.
example of usage :
priority = 0: for High priority like OTP messages.
priority = 5: used with general messages.
priority =10: Non-urgent promotional offers and notifications to your customers.
Default value : 10 $referenceId* : Your custom reference ID for this message.
$to="put_your_mobile_number_here";
$body="Hello world";
$priority=10;
$referenceId="SDK";
$api=$client->sendChatMessage($to,$body,$priority,$referenceId);
print_r($api);
Supported extensions ( jpg , jpeg , gif , png , svg , webp , bmp ) .
Max file size : 16MB .
Max Base64 length : 2,000,000
false : use a previously uploaded file instead of uploading it with each request
true : uploading it each request
$to="put_your_mobile_number_here";
$caption="image Caption";
$image="https://file-example.s3-accelerate.amazonaws.com/images/test.jpg";
$priority=10;
$referenceId="SDK";
$nocache=false;
$api=$client->sendImageMessage($to,$caption,$image,$priority,$referenceId,$nocache);
print_r($api);
Supported most extensions like ( zip , xlsx , csv , txt , pptx , docx ....etc ) .
Max file size : 100MB .
Max Base64 length : 2,000,000
$to="put_your_mobile_number_here";
$filename="image Caption";
$document="https://file-example.s3-accelerate.amazonaws.com/documents/cv.pdf";
$api=$client->sendDocumentMessage($to,$filename,$document);
print_r($api);
Supported extensions ( mp3 , aac , ogg ) .
Max file size : 16MB .
Max Base64 length : 2,000,000
$to="put_your_mobile_number_here";
$audio="https://file-example.s3-accelerate.amazonaws.com/audio/2.mp3";
$api=$client->sendAudioMessage($to,$audio);
print_r($api);
Max file size : 16MB .
Max Base64 length : 2,000,000
$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);
Supported extensions ( mp4 , 3gp , mov ) .
Max file size : 16MB .
Max Base64 length : 2,000,000
$to="put_your_mobile_number_here";
$caption="video Caption";
$video="https://file-example.s3-accelerate.amazonaws.com/video/test.mp4";
$api=$client->sendVideoMessage($to,$caption,$video);
print_r($api);
$to="put_your_mobile_number_here";
$link="https://ultramsg.com";
$api=$client->sendLinkMessage($to,$link);
print_r($api);
Example
14000000001@c.us
or
14000000001@c.us,14000000002@c.us,14000000003@c.us
Max length : 300 char, almost 15 contacts
$to="put_your_mobile_number_here";
$contact="14000000001@c.us";
$api=$client->sendContactMessage($to,$contact);
print_r($api);
Supports two lines. To use two lines, use the \n symbol.
Max length : 300 char . $lat* : Latitude $lng* : longitude
$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);
Max length : 4096 char
$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);
get the messages that sent by api
$page=1;
$limit=100;
$status="all";
$sort="asc";
$id="";
$referenceId="";
$from="";
$to="";
$ack="";
$api=$client->getMessages($page,$limit,$status,$sort,$id,$referenceId,$from,$to,$ack);
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);
or base64
$api=$client->getInstanceScreenshot("base64");
print_r($api);
Get connected phone informations : number , name , image etc..
$api=$client->getInstanceMe();
print_r($api);
sendDelay : Delay in seconds between sending message, Default 1 second
webhook_url : Http or https URL for receiving notifications .
webhook_message_ack : on/off ack (message delivered and message viewed) notifications in webhooks.
webhook_message_received : on/off notifications in webhooks when message received .
webhook_message_create : on/off notifications in webhooks when message create .
webhook_message_download_media : on/off to get received document / media files.
$api=$client->getInstanceSettings();
print_r($api);
Returns the active session if the device has connected to another instance of Web WhatsApp
$api=$client->sendInstanceTakeover();
print_r($api);
Logout from WhatsApp Web to get new QR code.
$api=$client->sendInstanceLogout();
print_r($api);
Restart your instance.
$api=$client->sendInstanceRestart();
print_r($api);
$sendDelay=1;
$webhook_url="";
$webhook_message_received=false;
$webhook_message_create=false;
$webhook_message_ack=false;
$webhook_message_download_media=false;
$api=$client->sendInstanceSettings($sendDelay,$webhook_url,$webhook_message_received,$webhook_message_create,$webhook_message_ack,$webhook_message_download_media);
print_r($api);
$api=$client->getChats();
print_r($api);
max value : 1000 .
$chatId="14155552671@c.us";
$limit=100;
$api=$client->getChatsMessages($chatId,$limit);
print_r($api);
$api=$client->getContacts();
print_r($api);
$chatId="14155552671@c.us";
$api=$client->getContact($chatId);
print_r($api);
$api=$client->getBlockedContacts();
print_r($api);
$chatId="14155552671@c.us";
$api=$client->blockContact($chatId);
print_r($api);
$chatId="14155552671@c.us";
$api=$client->unblockContact($chatId);
print_r($api);
$chatId="14155552671@c.us";
$api=$client->checkContact($chatId);
print_r($api);
Use Issues to contact me
Files (4) |
File | Role | Description |
---|---|---|
composer.json | Data | Auxiliary data |
LICENSE | Lic. | License text |
README.md | Example | Example script |
ultramsg.class.php | Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.