Get whatsapp group id

Before you can send message to whatsapp group, you have to know which group to send.

To get all the group you are in, there are 2 steps to do.

First, update all of your group list.

Then, get all of your groups id list and use them as target.

Update whatsapp group list

This API is used to update all of your groups.

This API should called only once : when you are joining new group or never call this API yet.

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.fonnte.com/fetch-group',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => array(
    'Authorization: TOKEN'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Read more about API update whatsapp group.

Then you can use API get whatsapp group to get all the group id.

Get whatsapp group list

This API will give you a list of all updated whatsapp group as previously updated using API update whatsapp group list.

This API will return nothing if you have never update the whatsapp group

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.fonnte.com/get-whatsapp-group',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => array(
    'Authorization: TOKEN'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

You can now get the id and the group name.

The group id will be used as target in the send message API.

Related knowledge

See more
Made with in Indonesia