I am not that new to Java Programming, but I have never worked with external libraries etc. Now I want to develop a desktop client for the “Telegram” open-source messaging platform, and I’m stuck when it comes to API-Usage.
There is pretty much documentation about the Telegram API, found at https://core.telegram.org/api, and I’ve already downloaded mtproto, telegram-api and tl-core from github, and compiled my own library jar from source by using gradle. As well, I’ve already written a small application, where the user clicks a button and is promted to enter his phone number, I’m using the Java-swing-Libraries and an ActionListener for this.
The phone number entered by the user should now be checked if it is already registered, the auth.checkPhone method seems to be capable for that. But how can I refer to it within my eclipse project? I don’t see any method “checkPhone” in any of the classes! What should I do?
Please help me, I can’t help myself and I am desperately stuck in my project. Even a small hint would help.
Thanks in Advance,
Lukas
2
Answers
Essentially you will have to fill out the blanks in the code given on GitHub in the ex3ndr/telegram-api repository. If you’ve got the library Jar file you built and the
tl-api-v12.jar
file on your Eclipse project’s Java build path, then look at the RPC Calls section of the README andFirst you need to set up an
AppInfo
object with your API credentials, then you will also have to create some new classes that implement theAbsApiState
andApiCallback
interfaces. Once these are available, you can create theTelegramApi
object and make an RPC call to the Telegram service as follows; in this case using the suggestedauth.checkPhone
method:The
TelegramApi
object represents your connection to the remote service, which is a request response style of API. RPC calls are made via thedoRpcCall
method, which takes a request object from theorg.telegram.api.requests
package (theTLRequestAuthCheckPhone
type in the example) filled in with the appropriate parameters. A response object (TLCheckedPhone
above) is then returned with the result when it is available.In the case of an asynchronous call the method returns immediately, and the
onResult
callback method is executed when the result is available:Or just look at this API https://github.com/pengrad/java-telegram-bot-api
It is really simple to use