⏳۵۰٪ تخفیف فقط تا پایان جشنواره؛ بعدش همهچیز به قیمت قبل برمیگرده!
مشاهده دورههاسلام
من یه کد php رو برای ربات تلگرامم روی سرور با ست وب هوک اجرا کردم اینو نمایش داد:
{"ok":true,"result":true
ولی توی ربات وقتی استارت میزنم هیچ اتفاقی نمیفته
کد رباتم هم اینه:
<?php
// Set your bot token here
$botToken = ':--UM9h8';
// Get updates from Telegram API
$update = filegetcontents('php://input');
$update = jsondecode($update, true);
// Get user information
$chatId = $update\['message'\]\['chat'\]\['id'\];
$userId = $update\['message'\]\['from'\]\['id'\];
$username = $update\['message'\]\['from'\]\['username'\];
// Send a message with the username and user ID
$response = "Username: @$username\\nUser ID: $userId";
// Prepare the API request
$apiUrl = "<https://api.telegram.org/bot$botToken/sendMessage>";
$data = \[
'chatid' => $chatId,
'text' => $response,
\];
// Send the message via Telegram API
$options = \[
'http' => \[
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => httpbuildquery($data),
\],
\];
$context = streamcontextcreate($options);
$result = filegetcontents($apiUrl, false, $context);
// Check if the message was sent successfully
if ($result === false) {
// Handle the error
echo "Failed to send message.";
} else {
// Message sent successfully
echo "Message sent.";
}
?>اولین نفری باشید که به این پرسش کمک میکند و مسیر حل مشکل را باز میکند.
اولین پاسخ را بنویسیدشاید پاسخ شما همینجا باشد