-
Notifications
You must be signed in to change notification settings - Fork 63
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 do basic RPC #12
Comments
I tried the sample works of @SireInsectus (https://github.com/SireInsectus/telegram-api-samples) but they end with |
I haven't had time to get follow up on the samples - the main problem being If you want to give me a friendly poke, I can take another look at it then. -//---------// On Mon, Apr 14, 2014 at 4:45 AM, Brian Lee [email protected] wrote:
|
@SireInsectus , thanks! I would love to see a follow up on your work. Please, do so. And if possible, update us here, via this thread for others to see. Thanks! |
@brain56 , you can use like this private static void login() throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(
System.in));
System.out.print("Loading fresh DC list...");
TLConfig config = api.doRpcCallNonAuth(new TLRequestHelpGetConfig());
apiState.updateSettings(config);
System.out.println("completed.");
System.out.print("Phone number for bot:");
String phone = reader.readLine();
System.out.print("Sending sms to phone " + phone + "...");
TLSentCode sentCode;
try {
sentCode = api.doRpcCallNonAuth(new TLRequestAuthSendCode(phone, 0,
5, "1c5c96d5edd401b1ed40db3fb5633e2d", "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, 5, "1c5c96d5edd401b1ed40db3fb5633e2d", "en"));
} else {
throw e;
}
}
System.out.println("sent.");
System.out.print("Activation code:");
String code = reader.readLine();
TLAuthorization auth = api.doRpcCallNonAuth(new TLRequestAuthSignIn(
phone, sentCode.getPhoneCodeHash(), code));
apiState.setAuthenticated(apiState.getPrimaryDc(), true);
System.out.println("Activation complete.");
System.out.print("Loading initial state...");
TLState state = api.doRpcCall(new TLRequestUpdatesGetState());
System.out.println("loaded.");
} |
@saturngod, I'm sorry, but I'm having a I initialized
Can you please tell me what I could be doing wrong? Thanks! |
@brain56 , try to add TLConfig for apiState after init the state like following TLConfig config = api.doRpcCallNonAuth(new TLRequestHelpGetConfig());
apiState.updateSettings(config); |
I did what you told me, so that now my intialization code looks like:
The problem now is that I timeout at:
Any thoughts on what's happening? Is my connection to |
I tested now and time out problem , too. |
Do you think it's a problem with our code or with the servers? |
no idea . Look like we miss something in the code. only @ex3ndr can answer this question. |
@brain56 , because of the layer12 api. I tested with layer 11 api and it's working fine. You can download at http://cl.ly/V9it/download/telegram-v11.zip and try again. API key from my.telegram.org is not working. Please use other api key and hash code. |
@saturngod Thanks for the help! But how do I get another API key and hash code if I'm not going to use the one provided in my.telegram.org? There was an issue about that and the answer to the question was to get the API key and hash code from my.telegram.org. |
@brain56 , now I am using APPI ID and hash code from https://github.com/SireInsectus/telegram-api-samples/blob/master/src/main/java/org/telegram/api/samples/support/SampleAppInfo.java. from It always response not authorise when I use app id and hash from http://my.telegram.org , |
@saturngod, thanks! I'll give it a shot. I also tweeted to Telegram weeks ago for some support, but they haven't replied yet. |
@saturngod , did you use the the same IP as the Telegram Samples project (109.239.131.195)? |
@brain56 no . 109.239.131.195 for register the developer account and it's not require anymore. |
Hi!@saturngod, @ex3ndr I test the telegram-api-samples with telegram-api-1.1.127-shadow.jar , but I get a problem, the problem is that I timeout at: |
i have this problem: |
@ilanta PHONE_NUMBER_UNOCCUPIED means that the number is not registered. |
@saturngod / @brain56 , Have you tried sending messages ..I have registered my application. |
thanks ashokcoolguys ! |
Hi can anybody send me compiled working code? I shall be thankful to you from the bottom of my heart. My email is [email protected] |
Hi. I will very thank to who that share a working code with me. i try to write it myself. but i need a good man's help. this is my email address [email protected] |
Hi! First and foremost, I'm new here. So if this is the wrong place to be writing this, please guide me accordingly. Please be kind!
How do I make a basic remote procedure call in Telegram? I've been searching for a tutorial for quite a while now but they all seem to be insufficient for beginners, even the readme on the Github page.
Please provide a guide from set up to finish on how to initialize a
TelegramApi
instance, how to use thedoRpcCall
method and how to properly extend fromTLMethod
. Please provide code on how to make anauth.sendCode
call from start to finish. Thank you very much! I'm sure this will be helping a lot of beginners.P.S.
I also posted a question in StackOverflow: http://stackoverflow.com/questions/23055525/how-to-do-a-basic-remote-procedure-call-rpc-in-telegram
The text was updated successfully, but these errors were encountered: