-
-
Save vttrz/6da6faa22714a184996c0c6ba0a73508 to your computer and use it in GitHub Desktop.
Send a message to a WhatsApp group from PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment