Skip to content

Instantly share code, notes, and snippets.

@whatsmate
Last active June 24, 2019 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save whatsmate/c79042e8d69758f241e1323d095a5874 to your computer and use it in GitHub Desktop.
Save whatsmate/c79042e8d69758f241e1323d095a5874 to your computer and use it in GitHub Desktop.
Send a message to a WhatsApp group from PHP
<?php
$INSTANCE_ID = "YOUR_INSTANCE_ID_HERE"; // TODO: Replace it with your gateway instance ID here
$CLIENT_ID = "YOUR_CLIENT_ID_HERE"; // TODO: Replace it with your Forever Green client ID here
$CLIENT_SECRET = "YOUR_CLIENT_SECRET_HERE"; // TODO: Replace it with your Forever Green client secret here
$postData = array(
'group_admin' => '12025550108', // TODO: Specify the WhatsApp number of the group creator, including the country code
'group_name' => 'Happy Club', // TODO: Specify the name of the group
'message' => 'Guys, party tonight?' // TODO: Specify the content of your message
);
$headers = array(
'Content-Type: application/json',
'X-WM-CLIENT-ID: '.$CLIENT_ID,
'X-WM-CLIENT-SECRET: '.$CLIENT_SECRET
);
$url = 'http://api.whatsmate.net/v3/whatsapp/group/text/message/' . $INSTANCE_ID;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData));
$response = curl_exec($ch);
echo "Response: ".$response;
curl_close($ch);
?>
@sidhartha-appy
Copy link

Hi,

How I will get the following data.

$INSTANCE_ID = "YOUR_INSTANCE_ID_HERE"; // TODO: Replace it with your gateway instance ID here
$CLIENT_ID = "YOUR_CLIENT_ID_HERE"; // TODO: Replace it with your Forever Green client ID here
$CLIENT_SECRET = "YOUR_CLIENT_SECRET_HERE"; // TODO: Replace it with your Forever Green client secret here

@kumarswamynh
Copy link

sdfgsd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment