event; // When received new incoming message if ($event == 'received::message') { $id = $getdata->data->id; $from = $getdata->data->from; $message = $getdata->data->message; $media_url = $getdata->data->media_url; $type = $getdata->data->type; $from_me = $getdata->data->from_me; $from_group = $getdata->data->from_group; if($type=='') {$type = 'text' ;} ; if($media_url!='') {$media_url = 'https://productions.wa-server.com' . $media_url ;} else {$media_url='-';} //Your Code start Here ----------------------------------------------------------------------------------------------------------------------------- $respon = "*This bot just reply your message :* ID : $id Text : $message From : $from Type : $type Media URL : $media_url" ; reply_txt ($id, $from, $respon, $type, $media_url ) ; } function reply_txt($id, $to, $msg, $wa_mode, $media) { // set your own API KEY here-------------------------------------------------------------------------------------------------------------------------- $host = 'https://productions.wa-server.com' ; $token = 'eyJhbGciOiJI4ee4UzI1NqeeiIsIn22R5cCiOjE2Mzg3N111111jkxMzMsImVY3MDMyNjczM30.XCCtA-GwgHQ5g_a_MExaQ7Qzg9PT18ZAok' ; $deviceid = '120' ; $devicekey = '2352ed-4459-8da3679ea44wwww232wwwwwe44fdeeea0' ; //----------------------------------------------------------------------------------------------------------------------------------------------------- $wa_mode=='text' ; if ($wa_mode=='text') { $url = "$host/messages/send-text" ; } else { $url = "$host/messages/send-media";} $dataarr = [ "to" => $to, "message" => $msg, "media_url"=> $media, "type"=> $wa_mode, "reply_for" => $id ]; $sendrest = json_encode($dataarr, true); $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_URL => $url, CURLOPT_SSL_VERIFYHOST => false , CURLOPT_SSL_VERIFYPEER => false , CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => $sendrest, CURLOPT_HTTPHEADER => [ "Authorization: Bearer $token", "Content-Type: application/json", "device-key: $devicekey" ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); } ?>