ERR_ALREADY_JOINED, i am getting this error

I am using CURL API’s

here is my code

public function test()
   $comet_uid = '1585030168';
   $guid = 'chat_1585585344';
   //$user = array('test0911', 'test09');
   $params = array(
       'participants' => ["superhero2", "superhero3"]
   // print_r($params);

   //The URL you're sending the request to.
   $url1 = '' . $comet_uid . '/groups/' . $guid . '/members';

   //Create a cURL handle.
   $ch1 = curl_init($url1);

   //Create an array of custom headers.
   $customHeaders1 = array(
       'accept: application/json',
       'content-type: application/json',
       'apikey: 1a37c973803a1dcf40f7923479d4e8fbb12c8888',
      'appid: 15311b5482de809'
  //Use the CURLOPT_HTTPHEADER option to use our
  //custom headers.
  curl_setopt($ch1, CURLOPT_HTTPHEADER, $customHeaders1);
  curl_setopt($ch1, CURLOPT_POSTFIELDS, $params);

  //Set options to follow redirects and return output
  //as a string.
  curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);

  //Execute the request.
  $result1 = curl_exec($ch1);
1 Like

Hi @Priyanka09,

The HTTP method for add member API is PUT:

Please use curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, 'PUT'); in your code.

Warm Regards,

Ketan Yekale
CometChat Pro


Thanks, it is solved

1 Like

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