Send Message by WhatsApp api using PHP

How to Send Message by WhatsApp API using PHP?

Introduction

In this tutorial, we will create a page to send WhatsApp message via api using php

Installation

Just download ultramsg.class.php or use Composer:

composer require ultramsg/whatsapp-php-sdk

Authentication

Sign up and Go to your instance dashboard and copy your Instance ID and Token which will be used for authenticating.

Example usage

Send your first WhatsApp message

require_once ('vendor/autoload.php'); // if you use Composer
//require_once('ultramsg.class.php'); // if you download ultramsg.class.php
	
$token="tof7lsdJasdloaa57e"; // Ultramsg.com token
$instance_id="instance1150"; // Ultramsg.com instance id
$client = new UltraMsg\WhatsAppApi($token,$instance_id);
	
$to="put_your_mobile_number_here"; 
$body="Hello world"; 
$api=$client->sendChatMessage($to,$body);
print_r($api);

What’s next?

you can also send ( Image , Document , Audio , Voice , Video , Link , Contact , Location , Vcard )

and setup webhook and receive messages and more ..

All the code, Full Documentation, is available on GitHub.

WhatsApp Chat WhatsApp Chat Hello, how can I help you ?