Skip to content

raphaelvserafim/classe-php-api-wa.me

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

WhatsApp API - PHP

Gerar InstΓ’ncia Key:

Acessar: api-wa.me

Swagger

Postman

Installing via composer

composer require raphaelvserafim/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->connect();

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 
echo $whatsapp->updateProfilePicture($url);

Download Media

    $body = [
    "mediaKey" => "", 
    "directPath" => "", 
    "url" => "",
    ] ;
$type = "image";// video | audio| image | sticker | document|
echo $whatsapp->downloadMediaMessage($type, $body);

Send Message

send Presence

$to     = '556696852025'; // if it's a group, use full id ex: [email protected]  
$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: [email protected]  
$text   = 'Hi';   
echo $whatsapp->sendText($to, $text);

send Audio

$to     = '556696852025'; // if it's a group, use full id ex: [email protected]  
$url    = ''; // your MP3 or OGG audio URL    
echo $whatsapp->sendAudio($to, $url);

send Media

Send Button

  $body = [
   "to" => "556696852025",
   "title" => "Are you enjoying ?",
   "footer" => "choose an option",
   "buttons" => [
       [
           "id" => "click_1",
           "text" => "Yes"
       ],
       [
           "id" => "click_2",
           "text" => "No"
       ]
   ]
];
echo $whatsapp->sendButton($body);

Send List

  $body = [
   "to" => "556696852025",
   "buttonText" => "Menu",
   "text" => "string", 
   "title" => "Menu",
   "description" => "Description",
   "footer" => "footer", 
   "sections" => [
       [
           "title" => "Pizza",
           "rows" => [
               [
                   "title" => "Pizza 01",
                   "description" => "Example pizza 01",
                   "rowId" => "1"
               ]
           ]
       ]
   ]
];
echo $whatsapp->sendList($body);

send Contact

$to     = '556696852025'; // if it's a group, use full id ex: [email protected]  
$name   = 'CACHE SISTEMAS';   
$number = '+556696883327';
echo $whatsapp->sendContact($to, $name, $number);

send Location

$to     = '556696852025'; // if it's a group, use full id ex: [email protected]  
$lat    =  37.7749;   
$lon    =  -122.4194;
$address = '123 Main St, San Francisco, CA';
echo $whatsapp->sendLocation($to, $lat, $lon, $address);

send Reaction

$to     = '556696852025'; // if it's a group, use full id ex: [email protected]  
$text   =  '😘';   
$msgId  =  '';
echo $whatsapp->sendReaction($to, $text, $msgId);

Group

Get list Group

   echo $whatsapp->listGroup();

Get infor Group

   $group_id = '[email protected]'; 
   echo $whatsapp->inforGroup($group_id);

Get Invite Code Group

   $group_id = '[email protected]'; 
   echo $whatsapp->groupInviteCode($group_id);

create Group

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

add Participants Group

   $group_id     = '[email protected]'; 
   $participants = ['556696852025'];
   echo $whatsapp->addParticipantsGroup($group_id, $participants);

Promote Participants Group Admin

   $group_id     = '[email protected]'; 
   $participants = ['556696852025'];
   $action = "promote"; // demote
   echo $whatsapp->promoteParticipantsGroup($group_id, $participants, $action);

Remove Participants Group

   $group_id     = '[email protected]'; 
   $participants = ['556696852025'];
   echo $whatsapp->removeParticipantsGroup($group_id, $participants);

Leave Group

   $group_id     = '[email protected]'; 
   echo $whatsapp->leaveGroup($group_id);