Erry215
Erry215

Reputation: 506

Telegram bot get forward_from user id

I'm trying to get the id of a user whose message has been forwarded. Like Message forwarded from X and I need to get X id

I tried with this but I don't receive anything about 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 result is

{
    "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"
}

It gives to me just his name

Upvotes: 1

Views: 2503

Answers (1)

Beppe C
Beppe C

Reputation: 13883

During forwarding the returned 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

If profile sharing is enabled this information should be available in forward_from field of the Message

Upvotes: 2

Related Questions