Telegram 机器人获取 forward_from 用户 ID
Telegram bot get forward_from user id
我正在尝试获取已转发其消息的用户的 ID。就像从 X 转发的消息一样,我需要获取 X id
我试过了,但我没有收到任何关于 forward_from
的信息
<?php
$update = file_get_contents('php://input');
$update = json_decode($update, TRUE);
$message = isset($update['message']) ? $update['message'] : "";
$reply = isset($message['reply_to_message']) ? $message['reply_to_message'] : "";
$reply_id_username = isset($reply['forward_from']['id']) ? $reply['forward_from']['id'] : "";
$reply 结果是
{
"message_id": 3,
"from": {
"id": BOT ID,
"is_bot": true,
"first_name": "X",
"username": "X_Bot"
},
"chat": {
"id": MY ID,
"first_name": "Me",
"username": "Me",
"type": "private"
},
"date": 1590679285,
"forward_sender_name": "User X",
"forward_date": 1590679285,
"text": "Text"
}
它只给我他的名字
转发过程中返回message object only provides forward_sender_name
(text with sender's name) if the user does not allow including the account information with the forwarded message. It is controlled by the Privacy Policy
如果启用了配置文件共享,则此信息应该在 Message
的 forward_from
字段中可用
我正在尝试获取已转发其消息的用户的 ID。就像从 X 转发的消息一样,我需要获取 X id
我试过了,但我没有收到任何关于 forward_from
的信息<?php
$update = file_get_contents('php://input');
$update = json_decode($update, TRUE);
$message = isset($update['message']) ? $update['message'] : "";
$reply = isset($message['reply_to_message']) ? $message['reply_to_message'] : "";
$reply_id_username = isset($reply['forward_from']['id']) ? $reply['forward_from']['id'] : "";
$reply 结果是
{
"message_id": 3,
"from": {
"id": BOT ID,
"is_bot": true,
"first_name": "X",
"username": "X_Bot"
},
"chat": {
"id": MY ID,
"first_name": "Me",
"username": "Me",
"type": "private"
},
"date": 1590679285,
"forward_sender_name": "User X",
"forward_date": 1590679285,
"text": "Text"
}
它只给我他的名字
转发过程中返回message object only provides forward_sender_name
(text with sender's name) if the user does not allow including the account information with the forwarded message. It is controlled by the Privacy Policy
如果启用了配置文件共享,则此信息应该在 Message
forward_from
字段中可用