1. Go to this page and download the library: Download craftivelabs/ci4-syncraft library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
craftivelabs / ci4-syncraft example snippets
use CraftiveLabs\Syncraft\SyncraftClient;
$client = new SyncraftClient('YOUR_API_KEY');
// Get joined groups
$groups = $client->getGroups();
foreach ($groups->groups as $group) {
echo $group->name; // "Developer Syncraft"
echo $group->participants; // 21
}
// Get channels
$channels = $client->getChannels();
// Check WhatsApp number
$check = $client->checkNumber('6281234567890');
$check->isRegistered; // true
// Bulk check numbers
$results = $client->checkNumbers(['6281234567890', '11234567890']);
use CraftiveLabs\Syncraft\DTO\WebhookEvent;
use CraftiveLabs\Syncraft\Webhook\Handler;
use CraftiveLabs\Syncraft\Webhook\WebhookTrait;
class MessageHandler implements Handler
{
use WebhookTrait;
public function handle(array $payload): void
{
$event = $this->parseEvent($payload);
if ($event->isMessageReceived()) {
$msg = $event->toMessageData();
log_message('info', "Message from {$msg->from}: {$msg->content}");
}
if ($event->isDeviceDisconnected()) {
$device = $event->toDeviceData();
log_message('error', "Device {$event->deviceId} disconnected");
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.