PHP code example of ativabot / php-sdk

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

    

ativabot / php-sdk example snippets


use AtivaBot\Client;

$client = Client::create(
    'seu-api-id-uuid',
    'seu-jwt-token'
);

// Enviar mensagem de texto
$response = $client->messages()->sendText(
    '5511999999999',
    'Olá! Mensagem enviada via SDK AtivaBot em PHP puro.'
);

// Enviar arquivo de mídia (imagem/PDF/áudio)
$mediaResponse = $client->messages()->sendMedia(
    '5511999999999',
    '/caminho/para/documento.pdf',
    'Legenda da mídia',
    'minha_chave_externa_123'
);

use AtivaBot\Laravel\Facades\AtivaBot;

// Enviar mensagem de texto
AtivaBot::messages()->sendText('5511999999999', 'Olá via Laravel Facade!');

// Criar um contato
AtivaBot::contacts()->create([
    'name'   => 'João Silva',
    'number' => '5511999999999',
    'email'  => '[email protected]'
]);

// Enviar template aprovado
AtivaBot::templates()->send([
    'to'           => '5511999999999',
    'templateId'   => 42,
    'language'     => 'pt_BR'
]);

use AtivaBot\Webhooks\WebhookHandler;

$payload = WebhookHandler::parse(); // Lê automaticamente php://input

if (WebhookHandler::isMessageStatusEvent($payload)) {
    $externalKey = $payload['externalKey'];
    $status      = $payload['status']; // delivered, read, failed
}
bash
composer 
bash
php artisan vendor:publish --tag="ativabot-config"