Whatsapp API Library v6 whiskeysockets

visit to Try :


DOC API

Send Whatsapp Message

Send a message to a new or existing chat. This function serves to send messages to the user

POSTsend
<?php
$curl =curl_init();
$data = ['number' => '6281xxx',// number sender
'type' => 'chat',// type delivery
'message' => 'try message 1',// message content
'to' => "628552xxx", // number receiver
];

curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_data($data) );
curl_setopt($curl, CURLOPT_URL, 'send');
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($curl);
curl_close($curl);

echo "<pre>";
print_r($result);

?>
                                

Request parameters:
number Required sender phone number. You can use the country code prefix . Example: 6281223xxxx
type Required type send
message Required Text message to be sent. Format: UTF-8 or UTF-16 string. for single newline (\n1 or PHP_EOL), double newline (\n2 or PHP_EOL PHP_EOL). maximum character is 1000
to Required receiver phone number. You can use the country code prefix . Example: 6281223xxxx