Telegram bot get get找不到chat找不到'当PHP中的消息转发时出错
我遇到的错误是:  糟糕的请求:找不到 当我想从机器人是管理员的组中转发一条消息时。
方案:
- 一个名为@puccipruebas的公共小组,其中bot(@comitentesbot)与我一起是管理员(@fpucci)。
- 测试用户(@fernandopucci)
- i(@fpucci)和测试用户(@fernandopucci)先前已私下写给bot。
这个想法是,当成员在小组中写作时,机器人将信息转发给我。
当我在小组中写入例如  这是一条测试消息时,bot会收到此数据:
Array (
[update_id] => 768460433
[message] => Array (
[message_id] => 8
[from] => Array (
[id] => 1026410801
[is_bot] =>
[first_name] => ??????????????????????¸ ???
[last_name] => ???????????????
[username] => FPucci
[language_code] => es
)
[chat] => Array (
[id] => -1001511892400
[title] => PucciPruebas
[username] => PucciPublico
[type] => supergroup
)
[date] => 1653597954
[text] => This is a test message
)
)
PHP中的代码是:
$tipo = $datain["message"]["chat"]["type"];
$chatid = $datain["message"]["chat"]["id"];
$msgid = $datain["message"]["message_id"];
$title = $datain["message"]["chat"]["title"];
if ("private"==$tipo || "PucciPruebas"==$title)
Reenviar("@fpucci", $chatid, $msgid);
function Reenviar ($a_chat, $from_chat, $message){
global $chatId, $comitentesapi;
$params=[
'chat_id' => "$a_chat",
'from_chat_id' => "$from_chat",
'message_id' => "$message",
];
$ch = curl_init("$comitentesapi/forwardMessage");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, ($params));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);
}
那么,我缺少,忘记或做错了什么?
- - - - -编辑 - - - - 我在 curl_close($ ch)之后附加,以下行作为发送消息的其他方式,并获得相同的结果:
file_get_contents("$comitentesapi/forwardMessage?disable_notification=true&chat_id=$a_chat&from_chat_id=$from_chat&message_id=$message&parse_mode=HTML");
I am getting errors like: Bad Request: chat not found when I want to forward a message from a group where the bot is an administrator.
Scenario:
- A public group called @PucciPruebas where the bot (@Comitentesbot) is an admin along with me (@fpucci).
- A test user (@fernandoPucci)
- I (@fpucci) and the test user (@fernandopucci) have previously written to the bot privately.
The idea is that when a member writes in the group, the bot forwards the message to me privately.
When I write in the group for example This is a test message, the bot receives this data:
Array (
[update_id] => 768460433
[message] => Array (
[message_id] => 8
[from] => Array (
[id] => 1026410801
[is_bot] =>
[first_name] => ??????????????????????¸ ???
[last_name] => ???????????????
[username] => FPucci
[language_code] => es
)
[chat] => Array (
[id] => -1001511892400
[title] => PucciPruebas
[username] => PucciPublico
[type] => supergroup
)
[date] => 1653597954
[text] => This is a test message
)
)
The code in PHP is:
$tipo = $datain["message"]["chat"]["type"];
$chatid = $datain["message"]["chat"]["id"];
$msgid = $datain["message"]["message_id"];
$title = $datain["message"]["chat"]["title"];
if ("private"==$tipo || "PucciPruebas"==$title)
Reenviar("@fpucci", $chatid, $msgid);
function Reenviar ($a_chat, $from_chat, $message){
global $chatId, $comitentesapi;
$params=[
'chat_id' => "$a_chat",
'from_chat_id' => "$from_chat",
'message_id' => "$message",
];
$ch = curl_init("$comitentesapi/forwardMessage");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, ($params));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);
}
So, what am I missing, forgetting, or doing wrong?
---------edit--------
I append after the curl_close($ch), the following line as other way to send the message, and get the same result:
file_get_contents("$comitentesapi/forwardMessage?disable_notification=true&chat_id=$a_chat&from_chat_id=$from_chat&message_id=$message&parse_mode=HTML");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论