PHP code example of cachesistemas / whatsapp

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

    

cachesistemas / whatsapp example snippets


 
use API\Container;
 
ntainer(["url" => "sua-url", "token" => "seu-token"]);

echo $container->criar(3, 500); // ID e Memória  
echo $container->stop(3);
echo $container->start(3);
echo $container->deletar(3);

echo $container->lista();
 

 
use API\WhatsApp;
 
atsApp([
    "apikey"     => "sua-key",
    "session"    => "3",
    "token"      => "seu-token",
    "url_api"    => "sua-url-api",
    "wh_connect" => "sua-url-webhook",
    "wh_qrcode"  => "sua-url-webhook",
    "wh_status"  => "sua-url-webhook",
    "wh_message" => "sua-url-webhook"
]);

 

 echo $whatsapp->sendPresena(array("chatId" => 5566996852025, "state" => "c"));  // c = digitando, r = gravando, a = online, p = offline
 

 echo $whatsapp->sendText(array("chatId" =>  5566996852025, "text" => "Oie"));
 

echo $whatsapp->sendImagem(array("chatId" => 5566996852025, "text" => "CACHE SISTEMAS", "url" => "https://www.cachesistemas.com.br/assets/files/graphic3-min.png"));
 

echo $whatsapp->sendAudio(array("chatId" =>  5566996852025, "url" => "https://ringtonazer.b-cdn.net/fetch/c3/c3dc619b099469663dae3a847273d793.mp3"));

echo $whatsapp->sendContato(array("chatId" => 5566996852025, "name" => "Raphael Serafim", "contact" => "66996852025"));

echo $whatsapp->sendLink(array("chatId" => 5566996852025, "text" => "Conheça a Cache Sistemas Visite o Nosso site", "url" => "https://www.cachesistemas.com.br"));

 echo $whatsapp->sendButtonAction(array("chatId" => 5566996852025, "title" => "Visitar o site",  "description" => "Visite agora", "buttonText" => "Acessar", "buttonSet" => "https://www.cachesistemas.com.br", "action" => "url"));

 echo $whatsapp->criarGrupo(array("name" => "API WhatsApp PHP", "participants" => "5566996852025"));


echo $whatsapp->mudarImagemGrupo(array("groupId" => "120363042927751450", "url" => "https://repository-images.githubusercontent.com/252264656/b0cf2c00-f436-11ea-9270-bf9297984c6b")); 

 echo $whatsapp->mudarDescricaoGrupo(array("groupId" => "120363042927751450", "description" => "PHP é vida !")); 

echo $whatsapp->obterContatos();
json
{"container":"api-3","session":"3","device":"556696883327","event":"on-message","type":"contact","isMedia":false,"pushName":"Raphael Serafim","id":"3ABFE08CA186BFD0DAEA","from":"556696852025","display":"Raphael","vcard":"BEGIN:VCARD\nVERSION:3.0\nN:;Raphael;;;\nFN:Raphael\nX-WA-BIZ-NAME:Raphael Serafim\nX-WA-BIZ-DESCRIPTION:Criação de sistemas web\nBots 🤖 \nDesenvolvimento de site \nIntegrações com APIs\nAplicativos Android\nTEL;type=CELL;type=VOICE;waid=556696852025:+55 66 9685-2025\nEND:VCARD","isgroup":false,"participant":"","timestamp":1648742161}