启动Telegram API实例 [英] Starting a Telegram API instance

查看:2621
本文介绍了启动Telegram API实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨! Telegram API初学者在这里!我正在开发一个PhoneGap应用程序,它使用电报API的消息服务。



我目前正在遵循API指南,我现在正在阅读身份验证的入门指南。但是,我发现它目前不足,而且不是 Jimmy Proof



如何在自己的应用程序中创建Telegram API实例?初始化后如何验证用户?从提供的链接,可以使用 auth.sendCode 方法。

引用中的一些文档 //github.com/ex3ndr/telegram-api\"> Git Hub网页 ...



要创建 TelegramApi 实例,必须首先创建 org.telegram.api.engine.storage.AbsApiState 类的自定义实现,并实现合适的方法。然后,自定义类实现的实例将用作 TelegramApi 构造函数方法的参数。



示例from Git Hub页面:

  TelegramApi api = new TelegramApi(new MyApiStorage(),new AppInfo(/ * ... put application信息在这里... * /),新的ApiCallback()
{
@Override
public void onApiDies(TelegramApi api){
//当auth键或用户授权b $ b}
@Override
public void onUpdatesInvalidated(TelegramApi api){
//当api引擎期望更新序列可能被破坏
}
});

对于 auth.sendCode 方法,此方法实际上是一个远程过程调用(RPC) ,并且不属于任何类在图书馆。这些是由客户端调用以由电报服务器执行的方法。有关详情,请参阅有关 TL 的电报常见问题解答。


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?

解决方案

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.

这篇关于启动Telegram API实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆