sejator/waba-sdk is a Laravel package for laravel sdk for whatsapp cloud api (waba).
It currently has 0 GitHub stars and 95 downloads on Packagist (latest version v1.1.2).
Install it with composer require sejator/waba-sdk.
Discover more Laravel packages by sejator
or browse all Laravel packages to compare alternatives.
Last updated
Laravel-native SDK untuk integrasi modern dengan WhatsApp Cloud API (WABA), Embedded Signup, dan arsitektur BSP multi-tenant.
SDK ini dirancang untuk:
composer require sejator/waba-sdk
php artisan vendor:publish --provider="Sejator\WabaSdk\WabaServiceProvider" --tag=waba-config
# Meta App
META_APP_ID=
META_APP_SECRET=
# Graph API
META_BASE_URL=https://graph.facebook.com/v25.0
# Runtime System User Token
META_SYSTEM_USER_TOKEN=
# Embedded Signup
META_CONFIGURATION_ID=
META_REDIRECT_URI=https://your-domain.com/embedded/callback
META_OAUTH_VERSION=v25.0
# Webhook
META_VERIFY_TOKEN=
<?php
return [
'meta' => [
'app_id' => env(
'META_APP_ID'
),
'app_secret' => env(
'META_APP_SECRET'
),
'api_version' => env(
'META_API_VERSION',
'v25.0'
),
'base_url' => sprintf(
'https://graph.facebook.com/%s',
env('META_API_VERSION', 'v25.0')
),
'access_token' => env(
'META_ACCESS_TOKEN'
),
'system_user_token' => env(
'META_SYSTEM_USER_TOKEN'
),
'business_id' => env(
'META_BUSINESS_ID'
),
],
'embedded' => [
'config_id' => env(
'META_CONFIGURATION_ID'
),
'redirect_uri' => env(
'META_REDIRECT_URI'
),
'oauth_version' => env(
'META_OAUTH_VERSION',
env('META_API_VERSION', 'v25.0')
),
'version' => env(
'META_EMBEDDED_VERSION',
'v4'
),
'auto_resolve_waba' => env(
'META_AUTO_RESOLVE_WABA',
true
),
'auto_subscribe_webhook' => env(
'META_AUTO_SUBSCRIBE_WEBHOOK',
true
),
'auto_fetch_phone_numbers' => env(
'META_AUTO_FETCH_PHONES',
true
),
'auto_fetch_templates' => env(
'META_AUTO_FETCH_TEMPLATES',
true
),
'state_ttl' => env(
'META_STATE_TTL',
300
),
],
'http' => [
'timeout' => env(
'WABA_HTTP_TIMEOUT',
30
),
'retry' => [
'times' => env(
'WABA_HTTP_RETRY_TIMES',
2
),
'sleep' => env(
'WABA_HTTP_RETRY_SLEEP',
500
),
],
],
];
src
├── Contracts
├── DTO
├── Enums
├── Exceptions
├── Services
├── Support
│ ├── Auth
│ └── Embedded
├── Utils
└── WabaServiceProvider
SDK menggunakan runtime token architecture.
Contoh:
use Sejator\WabaSdk\Services\Client;
use Sejator\WabaSdk\Services\MessageService;
$client = app(Client::class)
->withToken($device->access_token);
$messageService = new MessageService(
$client
);
$response = $messageService->text(
phoneNumberId: $device->phone_number_id,
to: '628xxxx',
text: 'Hello World'
);
$response = $messageService->media(
phoneNumberId: $device->phone_number_id,
to: '628xxxx',
type: 'image',
url: 'https://example.com/image.jpg',
caption: 'Image Caption'
);
$response = $messageService->media(
phoneNumberId: $device->phone_number_id,
to: '628xxxx',
type: 'document',
url: 'https://example.com/file.pdf',
caption: 'Invoice',
filename: 'invoice.pdf'
);
$response = $messageService->template(
$device->phone_number_id,
[
'to' => '628xxxx',
'template' => [
'name' => 'hello_world',
'language' => [
'code' => 'id'
],
],
]
);
use Sejator\WabaSdk\Services\MediaService;
$media = new MediaService($client);
$response = $media->upload(
$device->phone_number_id,
storage_path('app/image.jpg')
);
$binary = $media->download($mediaUrl);
use Sejator\WabaSdk\Services\TemplateService;
$templates = $service->all(
$device->waba_id
);
$response = $service->create(
$device->waba_id,
[
'name' => 'promo_template',
'language' => 'id',
'category' => 'MARKETING',
'components' => [
[
'type' => 'BODY',
'text' => 'Halo {{1}}'
]
],
]
);
use Sejator\WabaSdk\Services\EmbeddedSignupService;
use Sejator\WabaSdk\Support\Embedded\OAuthCallbackHandler;
$handler = app(
OAuthCallbackHandler::class
);
$session = $handler->createSession([
'context' => [
'tenant_id' => tenant()->id,
'user_id' => auth()->id(),
],
]);
$embedded = app(
EmbeddedSignupService::class
);
$signup = $embedded->signupUrl(
$session->state
);
$url = $signup['url'];
window.open(url, "metaEmbeddedSignup", "width=560,height=820");
$result = $handler->handle(
code: request('code'),
state: request('state')
);
$accessToken = $result->accessToken;
use Sejator\WabaSdk\Exceptions\GraphApiException;
try {
// SDK Call
} catch (GraphApiException $e) {
logger()->error(
$e->toArray()
);
}
$client = app(Client::class)
->withToken(
$device->access_token
);
$messageService = new MessageService(
$client
);
Disarankan callback route:
WhatsApp Cloud API mewajibkan: