1. Go to this page and download the library: Download phpjuice/wati-sdk 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/ */
phpjuice / wati-sdk example snippets
use Wati\Http\WatiClient;
use Wati\Http\WatiEnvironment;
use Wati\Api\GetContacts;
// Get this URL from your Wati Dashboard (API Docs section)
// It ($endpoint, $bearerToken);
$client = new WatiClient($environment);
// Use pre-built API classes
$response = $client->send(new GetContacts());
$contacts = json_decode($response->getBody()->getContents(), true);
use Wati\Http\WatiClient;
use Wati\Api\GetContacts;
class ContactController
{
public function __construct(
private readonly WatiClient $wati
) {}
public function index()
{
$response = $this->wati->send(new GetContacts());
return json_decode($response->getBody()->getContents(), true);
}
}
use Wati\Api\GetContacts;
// Get the first page with 50 contacts (default)
$response = $client->send(new GetContacts());
// Get a specific page with a custom page size
$response = $client->send(new GetContacts(pageNumber: 2, pageSize: 100));
use Wati\Http\Exceptions\AuthenticationException;
use Wati\Http\Exceptions\RateLimitException;
use Wati\Http\Exceptions\ValidationException;
use Wati\Http\Exceptions\WatiApiException;
use Wati\Http\Exceptions\WatiException;
try {
$response = $client->send(new GetContacts());
} catch (AuthenticationException $e) {
// Invalid bearer token - check credentials
} catch (RateLimitException $e) {
// Rate limited - wait and retry
$retryAfter = $e->getRetryAfter();
} catch (ValidationException $e) {
// Invalid request parameters
$errors = $e->getResponseData();
} catch (WatiApiException $e) {
// Other API errors (4xx, 5xx)
$statusCode = $e->getStatusCode();
} catch (WatiException $e) {
// Connection or other HTTP errors
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.