PHP code example of gradiwapp / gradiwapp-php-sdk

1. Go to this page and download the library: Download gradiwapp/gradiwapp-php-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/ */

    

gradiwapp / gradiwapp-php-sdk example snippets


use GradiWapp\Sdk\Client;
use GradiWapp\Sdk\Config;

$config = new Config(
    apiKey: 'your_key',
    apiSecret: 'your_secret'
);

$client = new Client($config);

$response = $client->messages()->sendText(
    to: '+123456',
    body: 'Hello from GradiWapp!'
);

public function send(GradiWapp\Sdk\Client $client)
{
    return $client->messages()->sendText(
        to: '+123456',
        body: 'Hello!'
    );
}

use GradiWapp\Sdk\Laravel\Facades\GradiWapp;

GradiWapp::messages()->sendText('+123456', 'Hello!');

$client->messages()->sendText('+123', 'Hello!');

$client->messages()->sendImage(
    '+123',
    'https://example.com/image.jpg',
    caption: 'Check this out!'
);

$client->messages()->sendMedia('+123', 'https://example.com/video.mp4');

$client->messages()->sendLocation(
    '+123',
    40.7128,
    -74.0060,
    name: 'NYC',
    address: 'New York'
);

$client->messages()->sendFile(
    '+123',
    fileUrl: 'https://example.com/doc.pdf',
    filename: 'Invoice.pdf'
);

$client->messages()->sendContact(
    '+123',
    contactsId: 'whatsapp_contact_id'
);

$client->messages()->sendReply(
    '+123',
    'This is a reply',
    replyToMessageId: '01ABC...'
);

$client->messages()->sendBoth(
    '+123',
    'Hello!',
    mediaUrl: 'https://example.com/pic.jpg',
    caption: 'Nice image'
);

ScheduleOptions::fromIso8601('2025-11-15T08:02:00+03:00');

ScheduleOptions::at(
    new DateTimeImmutable('2025-11-15 08:00'),
    'Africa/Cairo'
);

$client->messages()->getStatus('01ABC...');

$client->webhooks()->create(
    'delivery',
    'https://yourdomain.com/webhooks',
    secret: 'secret'
);

Webhooks::verifySignature($payload, $signature, $secret);

try {
    $client->messages()->sendText('+123', 'Hi');
} catch (ValidationException $e) {
    print_r($e->getErrors());
}

$client->messages()->sendText(
    '+123',
    'Hi',
    sessionId: 'session_01'
);

$client->messages()->sendText('+123', 'Hi', priority: 'high');
bash
composer 
bash
composer 
bash
php artisan vendor:publish --provider="GradiWapp\Sdk\Laravel\GradiWappServiceProvider" --tag=config