PHP code example of jhowbhz / package-apigratis

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

    

jhowbhz / package-apigratis example snippets


use ApiGratis\ApiBrasil;

$start = ApiBrasil::WhatsAppService("start", [
    "server_host" => "https://whatsapp2.contrateumdev.com.br",
    "apitoken" => "YOUR_API_TOKEN",
    "session" => "YOUR_SESSION_NAME",
    "sessionkey" => "YOUR_SESSION_KEY",
    "wh_status" => "", //optional
    "wh_message" => "", //optional
    "wh_connect" => "", //optional
    "wh_qrcode" => "", //optional
]);

echo $start;

use ApiGratis\ApiBrasil;

$qrcode = ApiBrasil::WhatsAppService("getQrCode?session=YOUR_SESSION_NAME&sessionkey=YOUR_SESSION_KEY", [
    "serverhost" => "https://whatsapp2.contrateumdev.com.br",
    "method" => "GET",
])

header("content-type: image/png");

echo $qrcode;

use ApiGratis\ApiBrasil;

$allchats = ApiBrasil::WhatsAppService("getAllChat", [
  "serverhost" => "https://whatsapp2.contrateumdev.com.br",
  "session" => "YOUR_SESSION_NAME",
  "sessionkey" => "YOUR_SESSION_KEY",
]);

echo $allchats;

use ApiGratis\ApiBrasil;

$getmessagesnumber = ApiBrasil::WhatsAppService("getMessagesChat", [
  "serverhost" => "https://whatsapp2.contrateumdev.com.br",
  "session" => "YOUR_SESSION_NAME",
  "sessionkey" => "YOUR_SESSION_KEY",
  "number" => "55995360492",
]);

echo $getmessagesnumber;

use ApiGratis\ApiBrasil;

$gethostdevice = ApiBrasil::WhatsAppService("getHostDevice", [
  "serverhost" => "https://whatsapp2.contrateumdev.com.br",
  "session" => "YOUR_SESSION_NAME",
  "sessionkey" => "YOUR_SESSION_KEY",
]);

echo $gethostdevice;

use ApiGratis\ApiBrasil;

$sendText = ApiBrasil::WhatsAppService("sendText", [
  "serverhost" => "https://whatsapp2.contrateumdev.com.br",
  "session" => "YOUR_SESSION_NAME",
  "sessionkey" => "YOUR_SESSION_KEY",
  "number" => "55995360492",
  "text" => "IS MY FIRST TEXT SEND FROM APIBRASIL.COM.BR"
]);

echo $sendText;

use ApiGratis\ApiBrasil;

$sendfile = ApiBrasil::WhatsAppService("sendFile", [
  "serverhost" => "https://whatsapp2.contrateumdev.com.br",
  "session" => "YOUR_SESSION_NAME",
  "sessionkey" => "YOUR_SESSION_KEY",
  "number" => "55995360492",
  "fileName" => "FILE_NAME"
  "path" => "https://www.euax.com.br/wp-content/uploads/2019/10/Teste.png"
  "caption" => "FILE_CAPTION"
]);

echo $sendfile;

use ApiGratis\ApiBrasil;

$sendfile64 = ApiBrasil::WhatsAppService("sendFile64", [
  "serverhost" => "https://whatsapp2.contrateumdev.com.br",
  "session" => "YOUR_SESSION_NAME",
  "sessionkey" => "YOUR_SESSION_KEY",
  "number" => "+55995360492",
  "fileName" => "FILE_NAME"
  "path" => "data:application/pdf;base64,....."
  "caption" => "FILE_CAPTION"
]);

echo $sendfile64;

use ApiGratis\ApiBrasil;

$sendaudio = ApiBrasil::WhatsAppService("sendAudio", [
  "serverhost" => "https://whatsapp2.contrateumdev.com.br",
  "session" => "YOUR_SESSION_NAME",
  "sessionkey" => "YOUR_SESSION_KEY",
  "number" => "+55995360492",
  "path" => "https://tuningmania.com.br/autosom/mp3/Sine%20sweep%20%2020%20kHz%20~%2020%20Hz.mp3"
]);

echo $sendaudio;

use ApiGratis\ApiBrasil;

$buttons = ApiBrasil::WhatsAppService("sendbutton", [
  "serverhost" => "https://whatsapp2.contrateumdev.com.br",
  "session" => "YOUR_SESSION_NAME",
  "sessionkey" => "YOUR_SESSION_KEY",
  "text" => "Teste de Envio de Mensagem com botoes",
  "title" => "Botões",
  "footer" => "Aqui vai o texto do rodapé da mensagem",
  "buttons" => [
        [
            "buttonId":"btn_sim", //get value in webhook
            "body" => ["displayText":"SIM" ]
        ],
        [
            "buttonId":"btn_nao", //get value in webhook
            "body" => ["displayText":"NÃO" ]
        ],
    ]
]);

echo $buttons;

use ApiGratis\ApiBrasil;

$groups = ApiBrasil::WhatsAppService("getAllGroups", [
  "serverhost" => "https://whatsapp2.contrateumdev.com.br",
  "session" => "YOUR_SESSION_NAME",
  "sessionkey" => "YOUR_SESSION_KEY",
]);

echo $groups;