0

I need to get user id of a specific phonenumber group and for this i user SendContact Telegram bot api method to share my phone numbers with my own chat id , but when i get telegram server response i don't get any chat id however my phone numbers are registered in telegram but telegram server send no response that include chat id of that phone number , just server return the phonenumber that i shared with the name that i choose for sharing that. please help me thanks. you can see telegram response to my request in next lines :

stdClass Object
(
    [ok] => 1
    [result] => stdClass Object
        (
            [message_id] => 98
            [from] => stdClass Object
                (
                    [id] => 12334567
                    [is_bot] => 1
                    [first_name] => botname
                    [username] => botusername
                )

            [chat] => stdClass Object
                (
                    [id] => myid
                    [first_name] => myfirstname
                    [username] => myusername
                    [type] => private
                )

            [date] => 1532279079
            [contact] => stdClass Object
                (
                    [phone_number] => 9891911111111
                    [first_name] => qqqq
                )
        )
)

1 Answers1

0

You can have a look at SendContact method

For response you will get Message object, that contains field from and field contact.

Both of them contains user_id/chat_id field.

In your stdClass Object chat_id is in result.from.id

  • I use the sendcontact method but the contact object does not represent user id as you saw in my stdclass object, and the fields that you mention them are my bot chat id and my telegram account chat id , I need the chat id of phone number that my bot send to me by send contact method – Mohsen Naderzadeh Jul 25 '18 at 06:30