Simplify your WhatsApp bot Development and Whapi.Cloud PHP SDKa comprehensive toolkit designed to streamline integration and automate messaging workflows. Whether you’re sending messages, managing groups, or building advanced customer interactions, the SDK makes it easy for developers to build powerful, scalable solutions.
Why choose Whapi.Cloud PHP SDK?
- No number migration required: Use your existing number, no need to migrate.
- Simple integration: Connect to any number via QR code for quick testing.
- Easily set up webhooks: Configure webhooks for instant messaging in just a few clicks.
- Comprehensive functionality: Send and receive text, media, files, locations, polls, and more through individual and group chats.
getting Started
1. Get your API token
Register and log in to your Whapi.Cloud Dashboard Authorize your number and generate an API token. This token will serve as the key to unlock SDK functionality.
2. Download SDK
Access the PHP SDK directly from the official GitHub repository: Download here.
3.Install SDK
Use Composer to install the SDK for dependency management:
composer require whapi-cloud/whatsapp-api-sdk-php
Set up your integration
Initialize client
To authenticate your API requests, initialize the client with your API token.
use OpenAPI\Client\Api\MessagesApi;
use OpenAPI\Client\Configuration;
// Initialize the client
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()
->setApiKey('token', "your_token")
->setAccessToken("your_token");
$apiInstance = new OpenAPI\Client\Api\MessagesApi(
new GuzzleHttp\Client(),
$config
);
Messaging API: Main features and examples
sending a text message
Send text messages easily using API. You can also include optional settings such as typing simulation or brief visibility.
$sender_text = new \OpenAPI\Client\Model\SenderText();
$sender_text->setTo('13016789891'); // Include country code
$sender_text->setBody('Your message here'); // Message content
$sender_text->setEphemeral(3600); // Message visibility time
$sender_text->setTypingTime(5.0); // Typing simulation duration
$result = $apiInstance->sendMessageText($sender_text);
print_r($result);
Retrieve messages using Webhooks
Webhooks provide instant updates to incoming messages, ensuring your bot remains up to date.
Retrieve multiple messages
Use the following example to retrieve a batch of messages.
$count = 100;
$offset = 0;
$result = $apiInstance->getMessages($count, $offset);
print_r($result);
Retrieve a single message
To get specific information via ID, use the following example:
$message_id = "your_message_id";
$result = $apiInstance->getMessage($message_id);
print_r($result);
For detailed webhook setup instructions, check out Webhooks Guide.
WhatsApp Groups API: Automated group management
Simplify the management of WhatsApp groups using Whapi.Cloud’s Groups API. These features allow you to automate tasks, save time and reduce manual work.
Main functions of group management
- Create, update or delete groups: Easily manage your WhatsApp groups programmatically.
- Participant management: Add, delete or block members as needed.
- Custom group settings: Easily adjust group name, avatar and permissions.
- Generate invitation link: Quickly create and share group invitation links for seamless onboarding.
Example: Create a group
Below is a practical example of how to create a new WhatsApp group using the API.
$create_group_request = [
"subject" => "Group Name",
"participants" => [
"13016789891",
"13016789892"
]
];
$result = $apiInstance->createGroup($create_group_request);
print_r($result);
Best Practices and Important Notes
Use phone number
When using the Whapi.Cloud API, follow these best practices for handling phone numbers:
- Always include country code: For example, use “13016789891” as the US number.
- Avoid special characters and spaces: Numbers should be entered as a continuous string of digits.
media requests
Make sure your media files meet the following standards to ensure smooth delivery:
- Publicly accessible URL: All media files must be hosted at a URL that can be accessed without authentication.
- Supported formats: Supports common image formats such as JPEG and PNG, as well as other standard file types.
Optimize messaging
For a more engaging and user-friendly experience, use the following options:
- short message: Set messages to disappear after a specific time for added privacy.
- Typing simulation: Simulates a typing indicator to provide a more natural and human interaction.
Why choose Wapi.Cloud?
Whapi.Cloud provides a powerful and user-friendly WhatsApp API gateway designed to make integration simple and efficient for developers. Here’s why it stands out:
- Comprehensive group management: Easily create, manage and automate WhatsApp groups, communities and channels.
- Interactive messaging feature: Add dynamic elements such as buttons, media sharing, polling and reactions to enhance communication.
- reliable support: Get fast and knowledgeable assistance from our team of professional care professionals to ensure your development process goes smoothly.
Whapi.Cloud’s transparency, flexibility and powerful documentation make it the ideal solution for scaling WhatsApp operations while maintaining control and efficiency.
Start today
Take the first step towards powerful WhatsApp automation Wapi.Cloud PHP SDK.
Getting Started Link:
Simplify your WhatsApp bot development and start building interactive solutions today.