Starting a Telegram API instance

ε祈祈猫儿з 提交于 2019-12-03 13:13:44

Referencing some documentation in the Git Hub page...

To create a TelegramApi instance, one must first create a custom implementation of the org.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 the TelegramApi constructor method.

Example from the Git Hub page:

TelegramApi api = new TelegramApi(new MyApiStorage(), new AppInfo(/*... put application information here...*/), new ApiCallback()
{
  @Override
  public void onApiDies(TelegramApi api) {
    // When auth key or user authorization dies
  }
  @Override
  public void onUpdatesInvalidated(TelegramApi api) {
    // When api engine expects that update sequence might be broken  
  }
});

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.

Charles Okwuagwu

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!