Using the Perl API, you can get it as follows: first you send a message to the bot from Telegram, then it displays getUpdates and there should be a chat identifier:
#!/usr/bin/perl use Data::Dumper; use WWW::Telegram::BotAPI; my $TOKEN = 'blablabla'; my $api = WWW::Telegram::BotAPI->new ( token => $TOKEN ) or die "I can't connect"; my $out = $api->api_request ('getUpdates'); warn Dumper($out); my $chat_id = $out->{result}->[0]->{message}->{chat}->{id}; print "chat_id=$chat_id\n";
The identifier should be in chat_id, but it may depend on the result, so I also added a dump of the whole result.
You can install the Perl API at https://github.com/Robertof/perl-www-telegram-botapi . It depends on your system, but I easily installed it on my Linux server:
$ sudo cpan WWW::Telegram::BotAPI
Hope this helps
Francesc Guasch Jul 27 '15 at 9:35 2015-07-27 09:35
source share