sendzap/laravel-sdk
Composer 安装命令:
composer require sendzap/laravel-sdk
包简介
A Laravel SDK to interact with the SendZap WhatsApp API.
README 文档
README
SendZap Laravel SDK
A clean and powerful Laravel SDK to interact with the SendZap WhatsApp API. Effortlessly manage instances, send text, media, bulk messages, buttons, and carousels directly from your Laravel application.
Requirements
- PHP 8.1+
- Laravel 10, 11, 12, or 13
CI only runs the test suite against Laravel 12 and 13, since 10 and 11 are
past their official security-support window and have no patched
laravel/framework release to test against. The SDK itself only depends on
illuminate/support (service container, facades), not the routing/validation
layer affected by those advisories, so it should keep working fine on 10/11
— just without automated coverage.
Installation and Usage
Installation
Install with Composer:
composer require sendzap/laravel-sdk
Usage
After publishing config and setting api_key and default_instance_id, use the facade or contract:
use Sendzap\Laravel\Facades\Sendzap; // or via constructor injection: Sendzap\Laravel\Contracts\SendzapClientContract Sendzap::sendText('5511999999999', 'Hello world');
You can install the package via composer:
composer require sendzap/laravel-sdk
After installing the package, run the installation command to publish the configuration file and set up your environment variables:
php artisan sendzap:install
This will:
- Publish the
config/sendzap.phpconfiguration file. - Append
SENDZAP_API_KEY,SENDZAP_BASE_URL, andSENDZAP_DEFAULT_INSTANCE_IDto your.envfile.
Configuration
Add your API Key and default Instance ID to your .env file:
SENDZAP_API_KEY=your_api_key_here SENDZAP_BASE_URL=https://api.sendzap.click/api/v1 SENDZAP_DEFAULT_INSTANCE_ID=your_default_whatsapp_instance_uuid
Usage
You can use the SDK either via the Sendzap Facade or by dependency-injecting the SendzapClient.
1. Sending Messages
Send a Simple Text Message
use Sendzap\Laravel\Facades\Sendzap; $response = Sendzap::sendText('22990000000', 'Hello from SendZap!');
Send Media (Image, Video, Document, Audio)
$response = Sendzap::sendMedia( to: '22990000000', mediaUrl: 'https://example.com/image.png', type: 'image', caption: 'Check out this image!', fileName: 'photo.png' // optional );
Send Interactive Buttons
to: '22990000000',
text: 'Do you agree with the terms?',
buttons: [
[
'buttonId' => 'yes_id',
'buttonText' => ['displayText' => 'Yes, I agree']
],
[
'buttonId' => 'no_id',
'buttonText' => ['displayText' => 'No']
]
],
footer: 'SendZap Interactive Buttons' // optional
);
#### Send a Carousel of Cards
```php
$response = Sendzap::sendCarousel(
to: '22990000000',
cards: [
[
'imageUrl' => 'https://example.com/item1.png',
'caption' => 'Product 1',
'footer' => 'Only $10',
'buttons' => [
['type' => 'url', 'displayText' => 'Buy Now', 'url' => 'https://example.com/buy/1']
]
],
[
'imageUrl' => 'https://example.com/item2.png',
'caption' => 'Product 2',
'footer' => 'Only $20',
'buttons' => [
['type' => 'url', 'displayText' => 'Buy Now', 'url' => 'https://example.com/buy/2']
]
]
],
text: 'Check out our new catalog:',
footer: 'Special offers'
);
Send Bulk Messages
$response = Sendzap::sendBulk( messages: [ ['to' => '22990000000', 'message' => 'Hello Alice!'], ['to' => '22990000001', 'message' => 'Hello Bob!'], ], delay: 5000 // Delay in ms between messages (default is handled by API) );
2. Managing Instances
List All Instances
$instances = Sendzap::listInstances();
Create a New Instance
$instance = Sendzap::createInstance('My New WhatsApp Business Instance');
Get Instance Status and Details
$details = Sendzap::showInstance('instance-uuid-here');
Get QR Code (Base64) to scan
$qr = Sendzap::getQr('instance-uuid-here'); // returns base64 image data to display in your frontend
Disconnect / Logout
Sendzap::logoutInstance('instance-uuid-here');
3. Using Multiple Instances Dynamically
If your application manages multiple WhatsApp accounts/instances, you can switch the active instance dynamically on the fly:
// Switch to a specific instance for the next call Sendzap::setInstanceId('another-instance-uuid')->sendText('22990000000', 'Dynamic instance message!');
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-01
