Hi! Telegram API beginner here! I’m developing a PhoneGap app that features a messaging service using the Telegram API.
I’m currently following the API guide and I’m now reading the getting started guide for authentication. However, I find that it is currently insufficient and not Jimmy Proof.
How does one create a Telegram API instance in one’s own app? After initialization how does one authenticate a user? From the link provided, this can be done with the auth.sendCode
method. But to what class does this method belong to?
2
Answers
Referencing some documentation in the Git Hub page...
To create a
TelegramApi
instance, one must first create a custom implementation of theorg.telegram.api.engine.storage.AbsApiState
class and implement the suitable methods. An instance of the custom class implementation will then be used as a parameter for theTelegramApi
constructor method.Example from the Git Hub page:
As for the
auth.sendCode
method, this method is actually an remote procedure call (RPC), and does not belong to any class in the library. These are methods invoked by the client to be executed by the Telegram server. See the Telegram FAQ regarding TL for more information.Take a look at this guide I put together here for getting started on writing your own Telegram-API code from scratch (code is in vb.net)
I think the online documentation for the API is poorly written, however if you can get familiar with it, then working through generating a Telegram AuthKey will be a good starting point.
The patterns and procedures that you build along the way are all reusable and will help you (eventually) write your own code, and have a good understanding of Telegram’s API
I think this a good approach.
Cheers.