telegram importContacts method not working - telegram

Could you please let me know why some of the telegram methods are not working?
for example "https://api.telegram.org/bot{token}/sendMessage" works fine and it never returns 404 error whereas https://api.telegram.org/bot{token}/importContacts and many others are not working at all.
You can find the list of all methods here and you can try them
https://core.telegram.org/methods
Thanks for responding

The Telegram platform offers two separate APIs.
Telegram Bot API which is documented at Telegram bot docs and relies on the HTTPS protocol. api.telegram.org is the entry point for this API.
Telegram Client API which is documented at Telegram core documentation and relies on the MTProto protocol.
The Telegram bot protocol is significantly more limited than the Telegram Core API, if you're looking to create a client to use your own account, you need to use the MTProto API.

Related

Get common channels with a user using Telegram API

I'm developing a mobile application using telegram API. There is a method called getCommonChats in Telegram API documentation.
My question is does this method return common channels too? or just common groups?

What is the web request to send a message to my telegram bot?

I tried this:
https://api.telegram.org/botXXtokenxx/sendMessage?chat_id=chat_id&text=text
But this is to send a message from the bot.
But what I need to do to send to the bot? (not from the bot)
You can either use a regular Telegram client (Telegram, Telegram X, Telegram Desktop, etc) to do it manually, or if you need an API (for whatever reason)...
You need the client API.
https://core.telegram.org/#getting-started
Once you have an API key for the client API and all that, you can send messages as explained here.
https://core.telegram.org/method/messages.sendMessage
Note that a human should be triggering this, as Telegram encourages (may be against ToS?) using a bot API for programatic access rather than the client API.

How to use telegram api for creating an android application?

I am trying to build a messaging app that can authenticate users and send messages using the telegram api. But I'm having problems with finding good documentations. Can anyone help me set up the api in my app from where I can implement the methods from the Telegram api?
Any help is appreciated.
The official Telegram API documentation is quite comprehensive.
Also you can use the new Telegram feature: TDLib. It handles all the encryption, network interaction and local storage. You can find documentation for TDLib in included javadoc (html).
See also:
Existing apps' source codes
MTProto docs
RU TDLib discussion board

Automate posting messages to a Telegram channel via API

I am new to the Telegram API.
I would like to automate posting messages to my public telegram channel.
I read a few posts that with bots I can achieve this, but I am not sure if that's the best way and whether the API has an option to directly post to a channel.
I would like to get some start points on how to achieve this?
Which API should I use?
Whether I need a dev account or bot, etc?
You can use bots to send message to channels. But there is some limitation, like size of files.
create your bot, by sending message to #botfather
add the bot to your channel. stackoverflow
write a code to send message to your channel. bot api
After 1 year of working with telegram API, I wanted to update this answer for best possible ways to interact with telegram API.
For posting to channels, both telegram API and telegram bot API can post to channels.
I worked directly with both the APIs, but I found the following clients for telegram API and bot API to be faster and easier to interact with telegram.
Telegram API client:
https://github.com/LonamiWebs/Telethon
Telegram bot API:
https://github.com/python-telegram-bot/python-telegram-bot
It is impossible to read messages from Telegram channels using Telegram Bot API.
In order to be able to scrape messages from Telegram channels that you do not own, you need to develop you own Telegram client that is capable of:
Joining your desired channels by links
Forwarding messages, arriving to the channels your client is subscribed to, to your own Telegram channel
In order to develop your own Telegram client, you need to use some implementation of MTProto.
You can find a lot of implementations of MTProto on https://github.com using mtproto keyword.
A few examples of well-documented implementations:
In PHP: https://github.com/danog/MadelineProto
In Python: http://github.com/LonamiWebs/Telethon
But probably it would be an overkill to develop your own solution to this problem if the only thing you want is to have several redirections from existing Telegram channels to your own channel.
There are applications that provide such a service.
For example, there is MultiFeed Bot from telespace.me team:
https://telespace.me/apps/multifeed_bot
It allows you to setup forwarding of messages within Telegram as well as redirections to external services.

Can I use telegram api for my commercial app?

I'm more confused how to use Telegram MTProto API, but still I want to know the truth, Can I use telegram API for mobile number verification or sending messages in my own commercial app(not related to telegram)?
Can I use telegram API for mobile number verification
I don't think so.
or sending messages in my own commercial app(not related to telegram)?
You can use Telegram Bot APIs (https://core.telegram.org/bots/api). In this case (bot service), Telegram is very open and explicitely declared to me the freedom to use Bot apps for commercial/profit purposes: see my twitter page: http://www.twitter.com/solyarisoftware !
You can also use channels for commercial messages.
your Question is Unclear
Actually, you can Create your own commercial app for yourself
to do that, you should use Telegram API, so your app is related to telegram
But it's completely not related to the telegram application you use now
for example mobile apps or windows application
Now, you write your own commercial app
you should Authenticate your phoneNumber with your own app
So, You should use telegram API for mobile number verification
Good Luck !!!

Resources