array(array(array( 'text' => '🔄 Reset', 'callback_data' => "reset_{$user}" ))) )); $data = http_build_query(array( 'chat_id' => $chat, 'message_thread_id' => $thread, 'text' => $text, 'parse_mode' => 'Markdown', 'reply_markup' => $markup, )); function tg_post($url, $data) { $ctx = stream_context_create(array('http' => array( 'method' => 'POST', 'header' => 'Content-Type: application/x-www-form-urlencoded', 'content' => $data, 'timeout' => 10, ))); return @file_get_contents($url, false, $ctx); } $r = tg_post("https://api.telegram.org/bot{$bot}/sendMessage", $data); if ($r === false) { http_response_code(500); echo "fail: http error"; exit; } $result = json_decode($r, true); if (isset($result['ok']) && $result['ok']) { echo "sent: " . $result['result']['message_id']; } else { http_response_code(500); echo "fail: " . (isset($result['description']) ? $result['description'] : 'no response'); }