telegram-s / telegram-api-old

Telegram Api library for java
MIT License
138 stars 64 forks source link

Got API_ID_INVALID while I'm sure about passed apiId and apiHash! #51

Closed yasserzamani closed 8 years ago

yasserzamani commented 8 years ago

My main is:

int apiId = X;
api = new TelegramApi(apiState, new AppInfo(apiId, "console", "???", "???", "en"), new MyApiCallback());
TLConfig config = api.doRpcCallNonAuth(new TLRequestHelpGetConfig());
apiState.updateSettings(config);
String phone = "+XXYYYZZZWWWW";
String apiHash = "AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH";
TLSentCode sentCode;
try {
    sentCode = api.doRpcCallNonAuth(new TLRequestAuthSendCode(phone, 0, apiId, apiHash, "en"));
} catch (RpcException e) {
    if (e.getErrorCode() == 303) {
        int destDC;
        if (e.getErrorTag().startsWith("NETWORK_MIGRATE_")) {
            destDC = Integer.parseInt(e.getErrorTag().substring("NETWORK_MIGRATE_".length()));
        } else if (e.getErrorTag().startsWith("PHONE_MIGRATE_")) {
            destDC = Integer.parseInt(e.getErrorTag().substring("PHONE_MIGRATE_".length()));
        } else if (e.getErrorTag().startsWith("USER_MIGRATE_")) {
            destDC = Integer.parseInt(e.getErrorTag().substring("USER_MIGRATE_".length()));
        } else {
            throw e;
        }
        api.switchToDc(destDC);
        sentCode = api.doRpcCallNonAuth(new TLRequestAuthSendCode(phone, 0, apiId, apiHash, "en"));
    } else {
        throw e;
    }
}

My apiState is exactly same as MemoryApiState.java.

But I get following log and error:

MTProto# 1001# Scheduller:Adding package: # 20 auth.sendCode# 768d5f4d (6314837243613675600, 21) MTProto# 1001# Scheduller:Sending Package (6314837243613675604, 22) ActorDispatcher:Dispatching action: schedule for scheduller MTProto# 1001# Transport5:Start reading message: pre MTProto# 1001# Transport5:Start reading message: 88 ActorDispatcher:Dispatching action: new for response MTProto# 1001:MTProtoMessage: pong# 347773c5 MTProto# 1001:pong: -2666168489377587629 MTProto# 1001# Scheduller:Forgetting message: # 15 MTProto# 1001# Transport4:Start reading message: pre MTProto# 1001# Transport4:Start reading message: 1112 ActorDispatcher:Dispatching action: new for response MTProto# 1001:MTProtoMessage: future_salts# ae500895 MTProto# 1001# Scheduller:Forgetting message: # 19 MTProto# 1001# Transport5:Start reading message: pre MTProto# 1001# Transport5:Start reading message: 104 ActorDispatcher:Dispatching action: new for response MTProto# 1001:MTProtoMessage: rpc_result# f35c6d01 MTProto# 1001:rpc_result: 6314837243613675600 TelegramApi# 1001:<< # 1 error # 400 API_ID_INVALID in 142 ms MTProto# 1001# Scheduller:Forgetting message: # 20 Exception in thread "main" org.telegram.api.engine.RpcException: API_ID_INVALID at org.telegram.api.engine.TelegramApi.doRpcCall(TelegramApi.java:366) at org.telegram.api.engine.TelegramApi.doRpcCallNonAuth(TelegramApi.java:428) at org.telegram.api.engine.TelegramApi.doRpcCallNonAuth(TelegramApi.java:420) at tg.Main.main(Main.java:34)

I'm sure that apiId, apiHash and phone number are same as which I get from telegram official site.

Could you please help me.

Thanks in advance.

yasserzamani commented 8 years ago

OK, I figured that out. We have to use production server ip!

HemmatSharp commented 7 years ago

سلام جناب یزدانی بنده هم مشکل شمارو دارم، اگه مشکلتون حل شده لطفا راهنمایی فرمایید خیلی ممنون خطا هنگام ارسال پیام از اپلیکیشن سی شارپ به تلگرام: API_ID_INVALID

yasserzamani commented 7 years ago

@shabahang4u , I used below IPs where are at tdesktop config.h

static const BuiltInDc _builtInDcs[] = {
    { 1, "149.154.175.50", 443 },
    { 2, "149.154.167.51", 443 },
    { 3, "149.154.175.100", 443 },
    { 4, "149.154.167.91", 443 },
    { 5, "149.154.171.5", 443 }
};