$content = file_get_contents("php://input"); $update = json_decode($content, true); 

This is a webcam bot telegram.

 if($update["message"]['text']=='start'): $chatID = $update["message"]["chat"]["id"]; // compose reply $reply = sendMessage(); // send reply $sendto =API_URL."sendmessage?chat_id=".$chatID."&text=".$reply; file_get_contents($sendto); endif; 

with the start command sends a message

  function sendMessage() { $message = urlencode("Для помощи нажмите /help. ".PHP_EOL."Для выбора города: /cities"); return $message; } 

Everything works .. As soon as I try to add a connection to the database in this command and create a request .. to extract for example the name of the city and send the name of the city in a message. stops working .. Something missed and what I do not understand ..

    1 answer 1

    $update["message"]['text'] == '/start' command comes "as is" including a slash. Regarding the connection to the database, make sure that the variables used for it are accessible within your function. Perhaps something should be passed to it in the call parameters.

    • I came .. an answer to the request .. just longer .. :( did not make a correction for the fact that the reaction rate would not be instantaneous - Durrasell
    • If longer - this is not normal. Requests / responses go equally fast. Probably you still had a mistake. It was only after the server was eliminated that the telegram could reach your bot and get an answer from it. - iosp