How to send media message to multiple recipients users and groups?

How do you send a media message to multiple users and groups? Currently, sending to mulitple recipients work on text message.

Hi @jeraldo,

Sending a media message to multiple users/groups is similar to text message.
The difference is just that instead of text, you’ll have to use the file property.
You can refer this for more details - https://prodocs.cometchat.com/reference#send-messages

Also, please go through this sample code snippet to understand better-

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "http://api-{region}.cometchat.io/v2.0/users/superhero5/messages",
  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_POSTFIELDS => array('receiver' => 'supergroup','receiverType' => 'group','category' => 'message','type' => 'image','multipleReceivers[uids][]' => 'superhero2','multipleReceivers[uids][]' => 'superhero3','file'=> new CURLFILE('/path/to/mediafile.png')),
  CURLOPT_HTTPHEADER => array(
    "appId: {appId}",
    "apiKey: {apiKey}",
    "Content-Type: application/json",
    "Accept: application/json",
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Thanks
-Siva

1 Like

Hi @jeraldo,

I hope the information shared by Siva was helpful. I am closing out this ticket due to inactivity.
Please feel free to write to us at help@cometchat.com if you require any further assistance.

Regards,
Rahul

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.