⏳۵۰٪ تخفیف فقط تا پایان جشنواره؛ بعدش همه‌چیز به قیمت قبل برمی‌گرده!

مشاهده دوره‌ها
ثانیه
دقیقه
ساعت
روز
راکت

مشکل اجرای ربات تلگرام با کد php

بدون پاسخ

سلام
من یه کد 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' =&gt; $chatId,  
'text' =&gt; $response,  
\];

// Send the message via Telegram API  
$options = \[  
'http' =&gt; \[  
'method' =&gt; 'POST',  
'header' =&gt; 'Content-Type: application/x-www-form-urlencoded',  
'content' =&gt; 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.";  
}  
?&gt;
ثبت پرسش جدید

پاسخ‌ها

0

هنوز پاسخی ثبت نشده

اولین نفری باشید که به این پرسش کمک می‌کند و مسیر حل مشکل را باز می‌کند.

اولین پاسخ را بنویسید

شاید پاسخ شما همین‌جا باشد

برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام