How to get the correct telegram channel id?

1) If I get user_id, "contacts.resolveUsername # bf0131c" and search on the string "channel", I get user_id = 0x0827ac18

But, if you send it to messages.getFullChat # 3b831c66, then you get the error "PEER_ID_INVALID". And, if I send, if users.getFullUser # ca30a5b1, then I get the error {"USER_ID_INVALID"}.

2) If I search for the string "channel" using contacts.search # 11f812d8, then I get two users with the username "ChannelBot" and "Channel_Bot", but I do not get with the username or channel "channel".

How to get the channel id to use in messages.getFullChat # 3b831c66? How to get chat_id by name?

+7
telegram
source share
2 answers

How to get chat_id for a private channel:

Make it public, give it @ChannelName Send a message to this channel through your bot API or cURL

https://api.telegram.org/bot111:222/ sendMessage?chat_id=@channelName & text = 123

It will return the channel id!

{ "ok" : true, "result" : { "chat" : { "id" : -?????????, "title" : "Test Private Channel", "type" : "channel" }, "date" : X, "message_id" : 7, "text" : "XXXXXX" } } 

Now you can convert the channel to private and use chat_id!

+6
source share

Just send a message from your channel to this bot: ( https://telegram.me/getidsbot )

+4
source share

All Articles