Bot API是一个基于HTTP的界面,专为那些热衷于为Telegram构建机器人的开发人员而设计,Telegram是一个带有文档API的即时消息应用程序。如果您正在编写电报机器人并且有关于Bot API的特定问题,请使用此标记。
我是新来的,我正在使用 ESP32 和一些传感器制作一个项目。所以基本上我想创建一个简单的温度和门传感器,通过 Telegram 连接到互联网。 我想要我的 es...
网站上已设置了一个表单,其中的数据将发送到电报机器人。 PHP脚本是这样的 网站上已设置了一个表格,其中的数据将发送到电报机器人。 PHP脚本是这样的 <?php echo $TOKEN; error_reporting(E_ALL); ini_set('display_errors', 1); require 'vendor/autoload.php'; use Dotenv\Dotenv; // Specify the path to the directory where the .env file is located $dotenvPath = __DIR__; // Create an instance of Dotenv and load environment variables $dotenv = Dotenv::createImmutable(dirname(__DIR__)); $dotenv->load(); // Get the token value $TOKEN = $_ENV['TOKEN']; // Telegram bot token and channel ID $TELEGRAM_CHAT_ID = "-1002017740876"; // Check for the presence of a POST request if ($_SERVER["REQUEST_METHOD"] == "POST") { // Collect data from the form $product = $_POST['product']; $name = $_POST['name']; $phone = $_POST['phone']; $email = $_POST['email']; $attachments = $_FILES['attachments']; $invoice = $_FILES['invoice']; // Save data to the database or file (depends on your requirements) // Send notification to Telegram $message = "<b>Promindustry</b>\n"; $message .= "<b>Product Name: </b>".$product." \n"; $message .= "<b>Sender: </b>".$name." \n"; $message .= "<b>Phone: </b>".$phone." \n"; $message .= "<b>Email: </b>".$email; file_get_contents("https://api.telegram.org/bot$TOKEN/sendMessage?chat_id=$TELEGRAM_CHAT_ID&parse_mode=html&text=".urlencode($message)); // Function to send a file to Telegram function sendFileToTelegram($document, $caption = '') { global $TOKEN, $TELEGRAM_CHAT_ID; $url = "https://api.telegram.org/bot$TOKEN/sendDocument"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, [ 'chat_id' => $TELEGRAM_CHAT_ID, 'document' => new CURLFile($document['tmp_name'], $document['type'], $document['name']), 'caption' => $caption ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $server_output = curl_exec($ch); curl_close($ch); } // Send files to Telegram if ($attachments['error'] == UPLOAD_ERR_OK) { sendFileToTelegram($attachments, 'Attachment: Signboard, part photo, other information'); } if ($invoice['error'] == UPLOAD_ERR_OK) { sendFileToTelegram($invoice, 'Attachment: Details for invoicing'); } // Send a response to the client (e.g., JSON response) echo json_encode([ "status" => "success", "message" => "Form submitted successfully!", ]); } else { // Send a response to the client about the invalid request method echo json_encode(["status" => "error", "message" => "Invalid request method!"]); } ?> 问题是只要文件大小小于 50 KB,一切都可以正常工作。一旦文件较大,就不会发送表格。 我将非常感谢您帮助解决这个问题。 我尝试重做脚本 此类行为最可能的原因可能是您的 php.ini 配置。 请找到您的 php.ini 文件并根据您的要求编辑这两行。 upload_max_filesize = 64M (change size as per your project requirement) post_max_size = 64M 还验证 telegram api 的文件限制(如果有)
如何让我的 Telegram 自动转发机器人在不引用的情况下转发?
我有一个机器人,可以自动将消息从通道 A 转发到组 B,并且我使用 Node.js 创建了这个机器人。机器人转发消息但显示它正在引用,我怎样才能让它显示为...
user_id 在函数调用后取值 None(telebot、sqlite3)
我正在使用远程机器人库制作一个电报机器人。该函数从 SQL3 数据库中检索用户先前在 city_living 变量中选择的居住城市。 定义
所以我花了几个月的时间来创建一个编辑器插件并对其进行验证。它现在以“未列出”的形式发布,但是,我无法让一些关键元素发挥作用。希望有人...
我们正在使用格莱美库开发一个 Telegram 机器人,并且遇到了一个问题:当尝试使用格莱美文档中的 sendAnimation 方法发送 GIF 文件时,它们被
使用 Telebot 停止 Telegram 机器人回调时出错
我正在使用 Python 中的 Telebot 库开发 Telegram 机器人。该机器人有一个主菜单,其中包含两个命令:/cep 和 /person。使用/cep命令时,用户必须输入邮政编码才能获取
我是 Python 新手,并且已使用 python-telegram-bot 库成功创建了一个 Python 机器人。此外,我还使用 Telethon 库编写了一个简单的脚本来收集统计信息
为什么机器人不发送消息? 我的代码: 导入电报 导入请求 bot_token = '令牌***' my_bot = telegram.Bot(token=bot_token) def get_chat_id(bot_token): request = requests.post(f'http...
Telegram 机器人发送的文件大小限制为 50MB。 我需要发送大文件。有没有办法解决? 我知道这个项目 https://github.com/pwrtelegram/pwrtelegram 但我可以......
这是我在该平台上的第一篇文章。我想要完成一项任务,并且需要有关如何实现它的建议。 我的电报帐户与数千人进行了数千次聊天......
Telegram bot api:sendPhoto 不渲染 html
我就是这样写消息的 常量回复电报 = { “chat_id”:米尔科, “照片”:row.image_url, “caption”:'Wo...
使用 telegram API(不是机器人 API)将我的联系人(其他用户)分享给其他用户,无需用户名
我有联系人并知道用户的 tg_id 和电话。如何使用 telegram API 向其他用户共享此联系人? 基本上,我只是想复制这个“共享此联系人”屏幕中的功能...
开发 Telegram API 机器人中的 Pyrogram 问题
我目前正在使用 Pyrogram 开发 Telegram API 机器人,但我遇到了一个正在努力解决的问题。目的是收集用户的电话号码并保存,
Telegraf BaseScene 自定义上下文与打字稿实现
我正在使用 Telegraf (v4.12.2) 和 typescript (v5.1.6) 编写一个电报机器人,并尝试实现该阶段。但由于某种原因无法使用我需要的字段设置自定义场景上下文。可能有些...
我有一个问题,如何通过提供用户名或聊天 ID 来获取用户的电话号码。我知道这个问题已经被问过很多次了,每个人都说没有任何程序......
在此输入图像描述 我有这个按摩,我如何开始部署我的项目? 我想将基于 Nodejs 构建的电报机器人连接到 Heroku。我发现了 i 中显示的图像...
在线程“pool-1-thread-1”java.util.ConcurrentModificationException中出现异常'并且数据未添加到数据库中
我正在尝试创建一个可以接受单词并将其保存到数据库的电报机器人(将来我想将其转换为学习西班牙语单词的助手) 出现了问题...
我使用gramjs库来访问Telegram API。 例如,我在频道中发布了一篇新帖子,其中包含 2 张图片和一些描述, 但我收到的不是一条消息(包含完整信息):描述 + ...