Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get an API ID #6

Closed
SireInsectus opened this issue Feb 28, 2014 · 14 comments
Closed

How to get an API ID #6

SireInsectus opened this issue Feb 28, 2014 · 14 comments

Comments

@SireInsectus
Copy link

I'm currently using the API ID and Hash specified in the Telegram-S project with some very basic calls. I'm sure you don't want me doing that long-term.

Reading the documentation at https://core.telegram.org/api/obtaining_api_id only helps at a conceptual level. Is there a quick solution for registering for an API ID? Possibly a Java implementation? Or can you do it for me?

What ever it takes to help us move forward.

@ex3ndr
Copy link
Collaborator

ex3ndr commented Feb 28, 2014

We have an idea that people might figure that by themself to understand basics of MTProto and Telegram Api

@SireInsectus
Copy link
Author

There is some merit to that thought but, that also defeats the purpose of a
high-level API. I can appreciate the TL language/protocol for what it is
but the reality is that once I establish the one? request I'll revert to
using the API for the rest of the work.

I do think you need to do something to filter out superfluous request for
access to your network... So I can respect that. Especially considering I'm
facing the same problem and I don't like my solutions any better.
On Feb 27, 2014 8:43 PM, "Stepan Korshakov" notifications@github.com
wrote:

We have an idea that people might figure that by themself to understand
basics of MTProto and Telegram Api

Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-36321518
.

@dmasoft
Copy link

dmasoft commented Feb 28, 2014

Anyway the method "register.saveDeveloperInfo" it is not implemented in the library. I tried to do my own implementation:

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import org.telegram.tl.StreamingUtils;
import org.telegram.tl.TLBool;
import org.telegram.tl.TLContext;
import org.telegram.tl.TLMethod;
import org.telegram.tl.TLObject;
/**

  • @author dmasoft
  • boolFalse#bc799737 = Bool;
  • boolTrue#997275b5 = Bool;
  • ---functions---
  • register.saveDeveloperInfo#d2dab7e9 name:string email:string phone_number:string age:int city:string = Bool;

*/

public class TLSaveDeveloperInfo extends TLMethod {

public static final int CLASS_ID = -757418007

;
private String name;
private String email;
private String phone_number;
private int age;
private String city;

public TLSaveDeveloperInfo(String name, String email, String phoneNumber, int age, String city)
  {
    this.setName(name);
    this.setEmail(email);
    this.setPhoneNumber(phoneNumber);
    this.setAge(age);
    this.setCity(city);
  }

  public TLBool deserializeResponse(InputStream stream, TLContext context)
    throws IOException
  {
    TLObject res = StreamingUtils.readTLObject(stream, context);
    if (res == null) {
      throw new IOException("Unable to parse response");
    }
    if ((res instanceof TLBool)) {
      return (TLBool)res;
    }
    throw new IOException("Incorrect response type. Expected TLBool, got: " + res.getClass().getCanonicalName());
  }



  public void serializeBody(OutputStream stream)
    throws IOException
  {
    StreamingUtils.writeTLString(this.getName(), stream);
    StreamingUtils.writeTLString(this.getEmail(), stream);
    StreamingUtils.writeTLString(this.getPhoneNumber(), stream);
    StreamingUtils.writeInt(this.getAge(), stream);
    StreamingUtils.writeTLString(this.getCity(), stream);
  }

  public void deserializeBody(InputStream stream, TLContext context)
    throws IOException
  {
    this.setName(StreamingUtils.readTLString(stream));
    this.setEmail(StreamingUtils.readTLString(stream));
    this.setPhoneNumber(StreamingUtils.readTLString(stream));
    this.setAge(StreamingUtils.readInt(stream));
    this.setCity(StreamingUtils.readTLString(stream));
  }

  public String toString()
  {
        return "register.saveDeveloperInfo#d2dab7e9";
  }

@Override
public int getClassId() {
    // TODO Auto-generated method stub
    return -757418007;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getEmail() {
    return email;
}

public void setEmail(String email) {
    this.email = email;
}

public String getPhoneNumber() {
    return phone_number;
}

public void setPhoneNumber(String phoneNumber) {
    this.phone_number = phoneNumber;
}

public int getAge() {
    return age;
}

public void setAge(int age) {
    this.age = age;
}

public String getCity() {
    return city;
}

public void setCity(String city) {
    this.city = city;
}

}

@SireInsectus
Copy link
Author

I appreciate that very much!

-//---------//
///\UNCHIE-///\ONSTER.com
Jacob-D-Parr--|--559-640-7277
General-Manager-/-Owner
www.MunchieMonster.com http://www.munchiemonster.com/

On Fri, Feb 28, 2014 at 12:27 AM, dmasoft notifications@github.com wrote:

Anyway the method "register.saveDeveloperInfo" it is not implemented in
the library. I tried to do my own implementation:

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import org.telegram.tl.StreamingUtils;
import org.telegram.tl.TLBool;
import org.telegram.tl.TLContext;
import org.telegram.tl.TLMethod;
import org.telegram.tl.TLObject;
/**

  • @author https://github.com/author dmasoft
  • boolFalse#bc799737 = Bool;
  • boolTrue#997275b5 = Bool;
  • ---functions---
  • register.saveDeveloperInfo#d2dab7e9 name:string email:string
    phone_number:string age:int city:string = Bool; * */

public class TLSaveDeveloperInfo extends TLMethod {

public static final int CLASS_ID = -757418007

;
private String name;
private String email;
private String phone_number;
private int age;
private String city;

public TLSaveDeveloperInfo(String name, String email, String phoneNumber, int age, String city)
{
this.setName(name);
this.setEmail(email);
this.setPhoneNumber(phoneNumber);
this.setAge(age);
this.setCity(city);
}

public TLBool deserializeResponse(InputStream stream, TLContext context)
throws IOException
{
TLObject res = StreamingUtils.readTLObject(stream, context);
if (res == null) {
throw new IOException("Unable to parse response");
}
if ((res instanceof TLBool)) {
return (TLBool)res;
}
throw new IOException("Incorrect response type. Expected TLBool, got: " + res.getClass().getCanonicalName());
}

public void serializeBody(OutputStream stream)
throws IOException
{
StreamingUtils.writeTLString(this.getName(), stream);
StreamingUtils.writeTLString(this.getEmail(), stream);
StreamingUtils.writeTLString(this.getPhoneNumber(), stream);
StreamingUtils.writeInt(this.getAge(), stream);
StreamingUtils.writeTLString(this.getCity(), stream);
}

public void deserializeBody(InputStream stream, TLContext context)
throws IOException
{
this.setName(StreamingUtils.readTLString(stream));
this.setEmail(StreamingUtils.readTLString(stream));
this.setPhoneNumber(StreamingUtils.readTLString(stream));
this.setAge(StreamingUtils.readInt(stream));
this.setCity(StreamingUtils.readTLString(stream));
}

public String toString()
{
return "register.saveDeveloperInfo#d2dab7e9";
}

@OverRide
public int getClassId() {
// TODO Auto-generated method stub
return -757418007;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public String getPhoneNumber() {
return phone_number;
}

public void setPhoneNumber(String phoneNumber) {
this.phone_number = phoneNumber;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

public String getCity() {
return city;
}

public void setCity(String city) {
this.city = city;
}

}

Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-36330416
.

@SireInsectus
Copy link
Author

I'm trying to develop the code for getting an API_ID but I've suddenly started to get connection time outs from 95.142.192.65:80.

@SireInsectus
Copy link
Author

There server still appears to be offline: http://95.142.192.65...

@dmasoft
Copy link

dmasoft commented Mar 3, 2014

You can try with 173.240.5.253:443
It's the one that I use.

@ex3ndr
Copy link
Collaborator

ex3ndr commented Mar 3, 2014

Yes, there are mistake in documents, there are old test server ip. You may use 173.240.5.253:443

@SireInsectus
Copy link
Author

With the new IP Address I get a BooleanTrue repsonse but no SMS message

Parameters 173.240.5.253:443:
Cosmic Push
jacob.parr@munchiemonster.com
+15596407277
38

Oakhurst

TelegramApi#1001:Phase 0 in 2 ms
TelegramApi#1001:Phase 1 in 128 ms
TelegramApi#1001:Timeout Iteration
TelegramApi#1001:Connection iteration
TelegramApi#1001:#1: waitForDc
TelegramApi#1001:#1: Creating proto for dc
TelegramApi#1001:#1: Creating key
TelegramApi#1001:Phase 2 in 4 ms
TelegramApi#1001:Sender iteration
api#1001#Downloader:DownloadFileThread iteration
api#1001#Downloader:DownloadFileThread iteration
api#1001#Downloader:DownloadFileThread iteration
api#1001#Downloader:DownloadFileThread iteration
api#1001#Uploader:UploadFileThread iteration
api#1001#Uploader:UploadFileThread iteration
api#1001#Uploader:UploadFileThread iteration
TelegramApi#1001:Phase 3 in 3 ms
api#1001#Uploader:UploadFileThread iteration
TelegramApi#1001:Timeout Iteration
TelegramApi#1001:>> #0: register.saveDeveloperInfo#d2dab7e9
TelegramApi#1001:Sender iteration
TransportRate:Transport: #1 173.240.5.253:443 #1.0
TransportRate:tryConnection #1
TransportRate:onConnectionSuccess #1
TransportRate:Transport: #1 173.240.5.253:443 #1.0
Authorizer:Solved PQ in 29 ms
TransportRate:Transport: #1 173.240.5.253:443 #1.0
TransportRate:tryConnection #1
TransportRate:Transport: #1 173.240.5.253:443 #1.0
TelegramApi#1001:#MTProto #1002 created in 866 ms
TelegramApi#1001:Connection iteration
TransportRate:tryConnection #1
TelegramApi#1001:Sender iteration
TelegramApi#1001:Connection iteration
MTProto#1001:sendMessage #2 register.saveDeveloperInfo#d2dab7e9
TelegramApi#1001:#> #0 sent to MTProto #1001 with id #2
TelegramApi#1001:Sender iteration
TransportRate:tryConnection #1
Scheduller:Prepare package: ping#7abe77ec of size 12
Scheduller:Total size: 12
Scheduller:Prepare package: ping_delay_disconnect#f3427b8c of size 16
Scheduller:Total size: 28
MTProto#1002#Scheduller:Iteration: count: 2, confirm:0
MTProto#1002#Scheduller:Building package
Scheduller:Prepare package: register.saveDeveloperInfo#d2dab7e9 of size 120
Scheduller:Total size: 120
Scheduller:Prepare package: ping#7abe77ec of size 12
Scheduller:Total size: 132
Scheduller:Prepare package: ping_delay_disconnect#f3427b8c of size 16
Scheduller:Total size: 148
MTProto#1001#Scheduller:Iteration: count: 3, confirm:0
MTProto#1001#Scheduller:Building package
MTProto#1002#Scheduller:Adding msg_ack: 0
MTProto#1001#Scheduller:Adding msg_ack: 0
MTProto#1002#Scheduller:Adding package: #3 ping#7abe77ec (5986652010772955140, 1)
MTProto#1001#Scheduller:Adding package: #2 register.saveDeveloperInfo#d2dab7e9 (5986652010772955140, 1)
MTProto#1002#Scheduller:Adding package: #6 ping_delay_disconnect#f3427b8c (5986652010772955144, 3)
MTProto#1001#Scheduller:Adding package: #4 ping#7abe77ec (5986652010772955148, 3)
MTProto#1002#Scheduller:Sending Package (5986652010772955152, 4)
MTProto#1001#Scheduller:Adding package: #5 ping_delay_disconnect#f3427b8c (5986652010772955156, 5)
MTProto#1001#Scheduller:Sending Package (5986652010772955160, 6)
Scheduller:Prepare package: ping#7abe77ec of size 12
Scheduller:Total size: 12
MTProto#1001#Scheduller:Iteration: count: 1, confirm:0
MTProto#1001#Scheduller:Building package
MTProto#1001#Scheduller:Single package: #7 ping#7abe77ec (5986652010772955164, 7)
MTProto#1001#Transport2:Start reading message: 100
MTProto#1001:Decrypted in 0 ms
MTProto#1001#BackOff:onSuccess
MTProto#1001#BackOff:reset
TransportRate:onConnectionSuccess #1
TransportRate:Transport: #1 173.240.5.253:443 #1.0
MTProto#1001:MessageArrived (#2): time: 1393876042
MTProto#1001:MessageArrived (#2): seqNo: 0, msgId:5986652016283285505
MTProto#1001:Salt check timeout
MTProto#1001:Too fiew actual salts: 0, requesting news
MTProto#1001:MTProtoMessage: bad_server_salt#edab447b
MTProto#1001:BadMessage: 48 #5986652010772955160
MTProto#1001:Reschedule messages because bad_server_salt #5986652010772955160
MTProto#1001#Scheduller:Resending as new #2
MTProto#1001#Scheduller:Resending as new #4
MTProto#1001#Scheduller:Resending as new #5
Scheduller:Prepare package: register.saveDeveloperInfo#d2dab7e9 of size 120
Scheduller:Total size: 120
Scheduller:Prepare package: ping#7abe77ec of size 12
Scheduller:Total size: 132
Scheduller:Prepare package: ping_delay_disconnect#f3427b8c of size 16
Scheduller:Total size: 148
Scheduller:Prepare package: get_future_salts#b921bd04 of size 8
Scheduller:Total size: 156
MTProto#1001#Scheduller:Iteration: count: 4, confirm:0
MTProto#1001#Scheduller:Building package
MTProto#1001#Scheduller:Adding package: #2 register.saveDeveloperInfo#d2dab7e9 (5986652015067922432, 9)
MTProto#1001#Scheduller:Adding package: #4 ping#7abe77ec (5986652015067922436, 11)
MTProto#1001#Scheduller:Adding package: #5 ping_delay_disconnect#f3427b8c (5986652015067922440, 13)
MTProto#1001#Scheduller:Adding package: #8 get_future_salts#b921bd04 (5986652015067922444, 15)
MTProto#1001#Scheduller:Sending Package (5986652015067922448, 16)
MTProto#1002#Transport3:Start reading message: 100
MTProto#1002:Decrypted in 0 ms
MTProto#1002#BackOff:onSuccess
MTProto#1002#BackOff:reset
TransportRate:onConnectionSuccess #1
TransportRate:Transport: #1 173.240.5.253:443 #1.0
MTProto#1002:MessageArrived (#3): time: 1393876042
MTProto#1002:MessageArrived (#3): seqNo: 0, msgId:5986652016300526593
MTProto#1002:Salt check timeout
MTProto#1002:Too fiew actual salts: 0, requesting news
MTProto#1002:MTProtoMessage: bad_server_salt#edab447b
MTProto#1002:BadMessage: 48 #5986652010772955152
MTProto#1002:Reschedule messages because bad_server_salt #5986652010772955152
MTProto#1002#Scheduller:Resending as new #3
MTProto#1002#Scheduller:Resending as new #6
Scheduller:Prepare package: ping#7abe77ec of size 12
Scheduller:Total size: 12
Scheduller:Prepare package: ping_delay_disconnect#f3427b8c of size 16
Scheduller:Total size: 28
Scheduller:Prepare package: get_future_salts#b921bd04 of size 8
Scheduller:Total size: 36
MTProto#1002#Scheduller:Iteration: count: 3, confirm:0
MTProto#1002#Scheduller:Building package
MTProto#1002#Scheduller:Adding package: #3 ping#7abe77ec (5986652015067922452, 5)
MTProto#1002#Scheduller:Adding package: #6 ping_delay_disconnect#f3427b8c (5986652015067922456, 7)
MTProto#1002#Scheduller:Adding package: #9 get_future_salts#b921bd04 (5986652015067922460, 9)
MTProto#1002#Scheduller:Sending Package (5986652015067922464, 10)
MTProto#1001#Transport4:Start reading message: 100
MTProto#1001:Decrypted in 0 ms
MTProto#1001#BackOff:onSuccess
MTProto#1001#BackOff:reset
TransportRate:onConnectionSuccess #1
TransportRate:Transport: #1 173.240.5.253:443 #1.0
MTProto#1001:MessageArrived (#4): time: 1393876042
MTProto#1001:MessageArrived (#4): seqNo: 0, msgId:5986652016812631041
MTProto#1001:MTProtoMessage: bad_server_salt#edab447b
MTProto#1001:BadMessage: 48 #5986652010772955164
MTProto#1001:Reschedule messages because bad_server_salt #5986652010772955164
MTProto#1001#Scheduller:Resending as new #7
Scheduller:Prepare package: ping#7abe77ec of size 12
Scheduller:Total size: 12
MTProto#1001#Scheduller:Iteration: count: 1, confirm:0
MTProto#1001#Scheduller:Building package
MTProto#1001#Scheduller:Single package: #7 ping#7abe77ec (5986652015067922468, 17)
MTProto#1001#Transport2:Start reading message: 228
MTProto#1001:Decrypted in 0 ms
MTProto#1001:MessageArrived (#2): time: 1393876042
MTProto#1001:MessageArrived (#2): seqNo: 2, msgId:5986652016883918849
MTProto#1001:MTProtoMessage: new_session_created#9ec20908
TelegramApi#1001:mtproto#1001: onSessionCreated
MTProto#1001#Transport2:Start reading message: 1124
MTProto#1001:MTProtoMessage: pong#347773c5
MTProto#1001:pong: -1158781071602078677
MTProto#1001#Scheduller:Forgetting message: #4
MTProto#1001:MTProtoMessage: pong#347773c5
MTProto#1001:pong: 4750776811803476840
MTProto#1001#Scheduller:Forgetting message: #5
MTProto#1001:MTProtoMessage: msgs_ack#62d6b459
TelegramApi#1001:<< #0 confirmed in 1570 ms
MTProto#1001:msgs_ack: 5986652015067922432
MTProto#1001:Decrypted in 1 ms
MTProto#1001:MessageArrived (#2): time: 1393876042
MTProto#1001:MessageArrived (#2): seqNo: 2, msgId:5986652016883848193
MTProto#1001:MTProtoMessage: future_salts#ae500895
MTProto#1001#Scheduller:Forgetting message: #8
MTProto#1002#Transport3:Start reading message: 196
MTProto#1002:Decrypted in 0 ms
MTProto#1002:MessageArrived (#3): time: 1393876042
MTProto#1002:MessageArrived (#3): seqNo: 2, msgId:5986652016904411137
MTProto#1002:MTProtoMessage: new_session_created#9ec20908
TelegramApi#1001:mtproto#1002: onSessionCreated
MTProto#1002:MTProtoMessage: pong#347773c5
MTProto#1002:pong: 5020351690711215102
MTProto#1002#Scheduller:Forgetting message: #3
MTProto#1002:MTProtoMessage: pong#347773c5
MTProto#1002:pong: -4930676513179708387
MTProto#1002#Scheduller:Forgetting message: #6
MTProto#1002#Transport3:Start reading message: 1124
MTProto#1001#Transport2:Start reading message: 84
MTProto#1001:Decrypted in 0 ms
MTProto#1001:MessageArrived (#2): time: 1393876042
MTProto#1001:MessageArrived (#2): seqNo: 3, msgId:5986652016922399745
MTProto#1001:MTProtoMessage: rpc_result#f35c6d01
MTProto#1001:rpc_result: 5986652015067922432
MTProto#1001:rpc_result: 5986652015067922432 #997275b5
TelegramApi#1001:<< #0 deserialized boolTrue#997275b5 in 0 ms
TelegramApi#1001:<< #0 boolTrue#997275b5 in 1575 ms
MTProto#1001#Scheduller:Forgetting message: #2
MTProto#1002:Decrypted in 0 ms
MTProto#1001#Transport4:Start reading message: 196
MTProto#1002:MessageArrived (#3): time: 1393876042
MTProto#1002:MessageArrived (#3): seqNo: 2, msgId:5986652016904358913
MTProto#1001:Decrypted in 0 ms
MTProto#1002:MTProtoMessage: future_salts#ae500895
MTProto#1002#Scheduller:Forgetting message: #9
MTProto#1001:MessageArrived (#4): time: 1393876042
MTProto#1001:MessageArrived (#4): seqNo: 4, msgId:5986652017381714945
MTProto#1001:Ignoring messages #5986652016883483649
MTProto#1001:Ignoring messages #5986652016922399745
MTProto#1001:MTProtoMessage: pong#347773c5
MTProto#1001:pong: -3393279963712460466
MTProto#1001#Scheduller:Forgetting message: #7

@panchogallagher
Copy link

dmasoft I have used your class but when I do the RPC call am getting an

TelegramApi#1001:mtproto#1001| RPC #2: Error #400 INPUT_FETCH_ERROR

Can anyone help me with this?

@Nic0w
Copy link

Nic0w commented Mar 11, 2014

I'm getting a TimeOutException after "Authorizer:Solved PQ in ... ms" with server 109.239.131.195:80 and with server 173.240.5.253:443

@brain56
Copy link

brain56 commented Apr 14, 2014

Hi! Why was this issue closed? I don't think a solution was reached here. I am currently having troubles getting an API_ID, and am hoping for an update to this thread. Thanks!

@saturngod
Copy link

@brain56 , you can get API_ID at https://my.telegram.org/myapp

Telegram will send the password to your telegram messenger

@brain56
Copy link

brain56 commented Apr 14, 2014

@saturngod, thanks! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants