beedelivery/client-php-api-wa-me

Classe PHP para comunicação com api-wa.me

v1.0.1 2024-01-22 19:03 UTC

This package is auto-updated.

Last update: 2024-10-22 20:53:06 UTC


README

Gerar Instância Key:

Acessar: api-wa.me

Swagger

Installing via composer

composer require beedelivery/client-php-api-wa-me

EXAMPLES

WHATSAPP
use Api\Wame\WhatsApp;

include_once 'vendor/autoload.php';

$whatsapp     = new WhatsApp(
    ["server" => "API server", 
    "key" => "Your Key Instance"]
    );

Get webhook

    $whatsapp->constructWebhook();
    $whatsapp->from->remoteJid; //  number that sent message
    $whatsapp->from->messageType; // video | text | audio| image | sticker | document| reaction | liveLocation | 
    $whatsapp->from->msgId;
    $whatsapp->from->pushName;
    $whatsapp->from->text; 

Exemple

if ($whatsapp->from->messageType === "text" && $whatsapp->from->text === "Hi") {
  $whatsapp->sendText($whatsapp->from->remoteJid, "Hello!");
}

Get QrCode HTML

echo $whatsapp->getQrCodeHTML();

Get QrCode Base64

echo $whatsapp->getQrCodeBase64();

Infor Instance

echo $whatsapp->inforInstance();

Update Webhook

$body = [
        "allowWebhook" => false,
        "webhookMessage" => "",
        "webhookGroup" => "",
        "webhookConnection" => "",
        "webhookQrCode" => "", 
        "webhookMessageFromMe"=>"", 
        "webhookHistory"=>""
    ]; 
echo $whatsapp->updateWebhook($body);

Logout

echo $whatsapp->logout();

Actions

Get List Contacts

echo $whatsapp->listContacts();

Get Profile Pic

echo $whatsapp->profilePic('556696852025');

Update Profile Name

echo $whatsapp->updateProfileName('Raphael Serafim');

Update Profile And Group Picture

$url =''; // url image 
$id  ='556696852025'; // if it's a group, use full id ex: 123456789@g.us 
echo $whatsapp->updateProfilePicture($id, $url);

Read Receipt

$MsgId ='';  
$to  ='556696852025'; // if it's a group, use full id ex: 123456789@g.us 
echo $whatsapp->readReceipt($to, $MsgId);

Download Media

  $body = [
    "messageKeys" => [
        "mediaKey" => "", 
        "directPath" => "", 
        "url" => "", 
        "messageType" => "" 
    ] 
  ];
echo $whatsapp->downloadMediaMessage($body);

Send Message

send Presence

$to     = '556696852025'; // if it's a group, use full id ex: 123456789@g.us  
$status = 'composing';   // unavailable | available | composing | recording | paused
echo $whatsapp->sendPresence($to, $status);

send Text

$to     = '556696852025'; // if it's a group, use full id ex: 123456789@g.us  
$text   = 'Hi';   
echo $whatsapp->sendText($to, $text);

send Audio

$to     = '556696852025'; // if it's a group, use full id ex: 123456789@g.us  
$url    = ''; // your MP3 or OGG audio URL    
$ptt    = true;
echo $whatsapp->sendAudio($to, $url, $ptt  );

send Media

$to         = '556696852025'; // if it's a group, use full id ex: 123456789@g.us  
$url        = '';
$type       = 'image'; //  image |  video | audio | document
$caption    = 'Hi';  
echo $whatsapp->sendMedia($to, $url, $type, $caption);

Send Button

   $body = [
       "to" => "556696852025",
       "data" => [
           "text" => "Recebeu ?",
           "buttons" => [
               [
                   "title" => "Sim",
                   "id" => "1"
               ],
               [
                   "title" => "Não",
                   "id" => "2"
               ]
           ],
           "footerText" => "Escolha uma opção"
       ]
   ];
echo $whatsapp->sendButton($body);

Send Template Buttons

   $body = [
       "to" => "556696852025",
       "data" => [
           "text" => "Finalizar a compra",
           "buttons" => [
               [
                   "type" => "urlButton", // replyButton | urlButton | callButton 
                   "title" => "Pagar",
                   "payload" => "https://api-wa.me"
               ]
           ],
           "footerText" => "Visite o site para finalizar"
       ]
   ];
echo $whatsapp->sendTemplateButtons($body);

Send List

   $body = [
       "messageData" => [
           "to" => "556696852025",
           "buttonText" => "Menu",
           "text" => "Esse nosso menu",
           "title" => "Menu",
           "description" => "veja nosso menu",
           "sections" => [
               [
                   "title" => "Menu 01",
                   "rows" => [
                       [
                           "title" => "Opção 01",
                           "description" => "essa é uma opção",
                           "rowId" => "1"
                       ],
                       [
                           "title" => "Opção 02",
                           "description" => "essa é outra opção",
                           "rowId" => "2"
                       ]
                   ]
               ]
           ],
           "listType" => 0
       ]
   ];
echo $whatsapp->sendList($body);

send Contact

$to     = '556696852025'; // if it's a group, use full id ex: 123456789@g.us  
$name   = 'CACHE SISTEMAS';   
$number = '+556696883327';
echo $whatsapp->sendContact($to, $name, $number);

send Location

$to     = '556696852025'; // if it's a group, use full id ex: 123456789@g.us  
$lat    = 35.000;   
$lon    = 20.000;
$address = 'Rua do fulando';
echo $whatsapp->sendLocation($to, $lat, $lon, $address);

send Reaction

$to     = '556696852025'; // if it's a group, use full id ex: 123456789@g.us  
$text   =  '😘';   
$msgId  =  '';
echo $whatsapp->sendReaction($to, $text, $msgId);

Group

Get list Group

   echo $whatsapp->listGroup();

Get infor Group

   $group_id = '123456789@g.us'; 
   echo $whatsapp->inforGroup($group_id);

Get Invite Code Group

   $group_id = '123456789@g.us'; 
   echo $whatsapp->groupInviteCode($group_id);

create Group

   $name = 'API PHP WhatsApp'; 
   $participants = ['556696852025'];
   echo $whatsapp->createGroup($name, $participants);

add Participants Group

   $group_id     = '123456789@g.us'; 
   $participants = ['556696852025'];
   echo $whatsapp->addParticipantsGroup($group_id, $participants);

Promote Participants Group Admin

   $group_id     = '123456789@g.us'; 
   $participants = ['556696852025'];
   echo $whatsapp->promoteParticipantsGroup($group_id, $participants);

Demote Participants Group

   $group_id     = '123456789@g.us'; 
   $participants = ['556696852025'];
   echo $whatsapp->demoteParticipantsGroup($group_id, $participants);

Set Who Can Send Message Group

   $group_id     = '123456789@g.us'; 
   // true = Admin; false= All 
   echo $whatsapp->setWhoCanSendMessageGroup($group_id, true);

Set Who Can Change Settings Group

   $group_id     = '123456789@g.us'; 
   // true = Admin; false= All 
   echo $whatsapp->setWhoCanChangeSettingsGroup($group_id, true);

Remove Participants Group

   $group_id     = '123456789@g.us'; 
   $participants = ['556696852025'];
   echo $whatsapp->removeParticipantsGroup($group_id, $participants);

Leave Group

   $group_id     = '123456789@g.us'; 
   echo $whatsapp->leaveGroup($group_id);