How to Send WhatsApp Alerts Using PHP with Wbiztool API

Automating WhatsApp alerts is crucial for businesses to keep customers informed and engaged. With Wbiztool’s API and PHP, you can easily send WhatsApp alerts for order updates, reminders, or notifications. This guide walks you through how to set up WhatsApp alerts using PHP and the Wbiztool API.

Step 1: Setting Up Your Environment

Ensure you have PHP installed on your server or in the local environment. You must also sign up for a Wbiztool account to get your API key.

Step 2: Install Required PHP Library

To send HTTP requests in PHP, we will use cURL. Make sure it’s installed on your server:

sudo apt-get install php-curl

Step 3: Write the PHP Script

Create a new PHP file, e.g., send_alert.php, and add the following code:

<?php
// API credentials from Wbiztool
$apiKey = 'YOUR_API_KEY';
$clientId = 'YOUR_CLIENT_ID';
$whatsappClient = 'YOUR_WHATSAPP_CLIENT_ID';

// The recipient's phone number
$phone = '1234567890';
$countryCode = '91';
$message = 'This is your custom alert notification.';

// Prepare the request payload
$data = array(
    'client_id' => $clientId,
    'api_key' => $apiKey,
    'whatsapp_client' => $whatsappClient,
    'phone' => $phone,
    'country_code' => $countryCode,
    'msg' => $message
);

// Convert data to JSON format
$jsonData = json_encode($data);

// Initialize cURL
$ch = curl_init('https://wbiztool.com/api/v1/send_msg/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);

// Execute cURL request
$response = curl_exec($ch);
curl_close($ch);

// Check the response
if ($response) {
    echo 'Alert sent successfully!';
} else {
    echo 'Failed to send alert.';
}
?>

Step 4: Execute the Script

Upload your PHP file to your server and run it in the browser or terminal. The script will send a custom WhatsApp alert using Wbiztool’s API.

Conclusion

With just a few lines of code, you can send automated WhatsApp alerts using PHP and Wbiztool. This process is perfect for efficiently sending reminders, notifications, or order updates. Start automating your WhatsApp alerts by exploring the Wbiztool API documentation.


Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top