Search code examples
phpwordpresscurlplugins

WordPress atom plugin create post based group chat with API


There is issue to create group while publish the post so I want to create post based group. Is there any example / sample of API calling?

I have added the plugin of atom WordPress chatting on my site and expecting to enable the post base group chat from backend but its not available there.


Solution

  • I Have just saw there is api and fixed it just want to share my api code with my software developers here it is the api i have called after post is published in my site

            $curl = curl_init();
            curl_setopt_array($curl, [
            CURLOPT_URL => 'https://api.cometondemand.net/api/v2/createGroup',
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => "",
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 30,
            
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => "POST",
            CURLOPT_HTTPHEADER => [
                "Accept: application/json",
                "Content-Type: application/x-www-form-urlencoded",
                'Api-Key: your-atom-apikey'
            ],
            CURLOPT_POSTFIELDS=> "GUID=GroupId&name=Groupname"
    
            ]);
            
            $response = curl_exec($curl);
            $err = curl_error($curl);
            
            curl_close($curl);
            
            if ($err) {
                echo "cURL Error #:" . $err;
            } else {
                echo $response;
            //  echo "<script>alert(".$post_id.")</script>";
            
            };