raphaelvserafim / client-php-api-wa-me
Classe PHP para comunicação com api-wa.me
Installs: 1 404
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 3
Forks: 9
Open Issues: 1
Requires
- ext-curl: *
README
About Our WhatsApp API
🔓 Unlock the Potential of WhatsApp: Powerful Integration with Our Unofficial API!
Efficient Group Management on WhatsApp
📋 Our stable, though unofficial, API allows for efficient management of WhatsApp groups. Simplify administration, and easily add or remove members.
Versatile Message Sending
💬 With our API, you can send text, audio, video, and image messages quickly and easily. Adapt to your business communication needs comprehensively.
Receive Instant Events
🔔 Stay updated with our API, receiving real-time events when new messages are received. Stay connected and agile in responding to interactions on WhatsApp.
🔗 Create Your Account: Visit https://api-wa.me/sign-up to create your account and start using our API today!
🎁 Special Discount: Use the coupon GIT20 and get 20% off on your first instance!
Contact Support
- Name: Raphael Serafim
- Email: support@api-wa.me
- Website: https://api-wa.me
Installing via composer
composer require raphaelvserafim/client-php-api-wa-me
EXAMPLES
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" => 1, // 1=true or 0=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);
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 echo $whatsapp->sendAudio($to, $url);
send Image
$to = '556696852025'; // if it's a group, use full id ex: 123456789@g.us $url = ''; $caption = ''; echo $whatsapp->sendImage($to, $url);
send Video
$to = '556696852025'; // if it's a group, use full id ex: 123456789@g.us $url = ''; $caption = ''; echo $whatsapp->sendVideo($to, $url);
send Document
$to = '556696852025'; // if it's a group, use full id ex: 123456789@g.us $url = ''; $caption = ''; $mimetype = 'application/pdf'; // https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types $fileName=''; echo $whatsapp->sendDocument($to, $url, $mimetype, $fileName);
Send Button Action
$body = [ 'to' => '14375223417', 'header' => [ 'title' => 'Example Title', 'hasMediaAttachment' => true, 'imageMessage' => [ 'url' => 'https://raphaelvserafim.com/og-image.png' ] ], 'text' => 'This is a test', 'footer' => 'choose an option', 'buttons' => [ [ 'type' => 'cta_copy', 'copy_code' => '1234567890', 'text' => 'Copy barcode' ], [ 'type' => 'cta_url', 'url' => 'https://api-wa.me', 'text' => 'Access the website' ], [ 'type' => 'cta_call', 'phone_number' => '+14375223417', 'text' => 'Call us' ] ] ]; echo $whatsapp->sendButton($body);
Send Button Reply
{ "to": "14375223417", "header": { "title": "Example Header", "hasMediaAttachment": true, "imageMessage": { "url": "https://raphaelvserafim.com/og-image.png" } }, "text": "This is a test", "footer": "choose an option", "buttons": [ { "type": "quick_reply", "id": "uniqId1", "text": "Yes" }, { "type": "quick_reply", "id": "uniqId2", "text": "No" } ] } echo $whatsapp->sendButtonReply($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: 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 = 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: 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']; $action = "promote"; // demote echo $whatsapp->promoteParticipantsGroup($group_id, $participants, $action);
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);