8

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?

brain56
  • 2,659
  • 9
  • 38
  • 70
  • can you guid me how you had create application becuase recenly i am going to create application but it's giving me error i want app id and api_hash – CoronaPintu May 28 '14 at 06:31
  • You can get your app id and api hash from your my.telegram.org page. – brain56 May 28 '14 at 15:25
  • recently u had create new application it giving error it givining only error dialog when cick on create application – CoronaPintu May 29 '14 at 05:50
  • I'm sorry. I'm not sure I can understand you. Can you post screenshots or post a separate question regarding your issue? – brain56 May 29 '14 at 08:29
  • it's solve it's api.telegram.org site issue now they can allow to create application – CoronaPintu May 30 '14 at 05:37
  • See my answer here for an example of making RPC calls to the Telegram service - http://stackoverflow.com/questions/22635355/using-telegram-api-for-java-desktop-app/24472152#24472152 – grkvlt Sep 16 '14 at 07:06

2 Answers2

6

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.

brain56
  • 2,659
  • 9
  • 38
  • 70
0

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.

Community
  • 1
  • 1
Charles Okwuagwu
  • 10,538
  • 16
  • 87
  • 157