ChatBot API Schnittstelle
Start new chat
/sendMessage (Swagger)
<?php $dateTime = new DateTime('now'); $botIdentifier = YOUR_BOT_IDENTIFIER; $clientId = substr($botIdentifier,2, 10)."-".getRandomString(16)."-".substr($dateTime->format('u'),1,3); $url = "https://bot.chatbot4you.de/restApi/cb4you/sendMessage?botIdentifier=YOUR_BOT_IDENTIFIER"; $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => 1, CURLOPT_POST => 1, CURLOPT_URL => $url, CURLOPT_POSTFIELDS => [ "clientId" => $clientId, "currentHref" => YOUR_CURRENT_PAGE_URL, "message" => YOUR_MESSAGE, "tempId" => YOUR_TEMP_ID, "isDirect" => 1 // only when button clicked "directId" => YOUR_BUTTON_DIRECT_ID // only when button clicked (you can find directId in previous response) ], CURLOPT_SSL_VERIFYPEER => false ]); $response = curl_exec($curl); curl_close($curl); function getRandomString($length = 8) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $string = ''; for ($i = 0; $i < $length; $i++) { $string .= $characters[mt_rand(0, strlen($characters) - 1)]; } return $string; } ?>