Open SadeghHayeri opened 8 years ago
change your connection protocol of your client app to http in order to see the result! @SadeghHayeri
I try with 'HTTP' and "TCP' but doesn't work again :( i try connect with Termgram and it doesn't work too ( for first time it can access to telegram but when i close it and run it again, it cant access and stop working! )
@farhadamjady
can you send your code? client.isReady() function can help you to find your client has totally ready or not maybe it returns false for you... @SadeghHayeri
var telegramLink = require('telegram.link')(); var os = require('os'); var client = telegramLink.createClient( { id: [app_id], hash: '[app_hash_id]', version: '1.2.3', lang: 'fa', deviceModel:os.type(), connectionType:"TCP", systemVersion:os.platform() + '/' + os.release(), authKey:{id:'id'} }, telegramLink.TEST_PRIMARY_DC, function(ex){ if(!ex){ client.createAuthKey(function (auth) { client.messages.getDialogs (5,6,7,function(result){ console.log("result",result) }) }); } }
my code works correctly
@farhadamjady I use your code and get id and hash from /myapp
in first time, i use signup and signin to get authKey my authKey is like this:
{
"key": {
"id": {
"type": "Buffer",
"data": [1, 2, 3, ...]
},
"value": {
"type": "Buffer",
"data": [1, 2, 3, ...]
}
},
"serverSalt": {
"type": "Buffer",
"data": [1, 2, 3,...]
}
}
but in your code, you only use id!
I try run this code:
var telegramLink = require('telegram.link')();
var os = require('os');
var client = telegramLink.createClient({
id: 56***,
hash: '5abd96ef7120e1213ba4b7c4c******',
version: '1.2.3',
lang: 'fa',
deviceModel: os.type(),
connectionType: "TCP",
systemVersion: os.platform() + '/' + os.release(),
authKey: {
"key": {
"id": {
"type": "Buffer",
"data": [33, ***, 14]
},
"value": {
"type": "Buffer",
"data": [21, *********, 74, 188]
}
},
"serverSalt": {
"type": "Buffer",
"data": [98, 161, ****, 137, 230]
}
}
},
telegramLink.TEST_PRIMARY_DC,
function(ex) {
if (!ex) {
client.createAuthKey(function(auth) {
client.messages.getDialogs(5, 6, 7, function(result) {
console.log("result", result)
})
});
}
});
but get other error again:
[INFO] Mon, 05 Sep 2016 02:33:48 GMT net.EncryptedRpcChannel Call of 'mtproto.service.invokeWithLayer' took 203ms
[INFO] Mon, 05 Sep 2016 02:33:48 GMT net.EncryptedRpcChannel New session has been created by Telegram: { T:mtproto.type.New_session_created, first_msg_id: "0x57cd3c0371eb7f64", unique_id: "0x28d26e1c36eb55f0", server_salt: "0xe4c2522632307c6e" }
[INFO] Mon, 05 Sep 2016 02:33:48 GMT net.EncryptedRpcChannel Send the ack to the server: { T:mtproto.type.Msgs_ack, msg_ids: { T:Vector, type: "Long", list: ["0x57cd3c0334ba4801"] } }
[INFO] Mon, 05 Sep 2016 02:33:48 GMT net.EncryptedRpcChannel The server sent a acknowledge for the followings [0x57cd3c0371eb7f64]
[INFO] Mon, 05 Sep 2016 02:33:48 GMT net.EncryptedRpcChannel Call of 'mtproto.type.Msgs_ack' took 39ms
[INFO] Mon, 05 Sep 2016 02:33:48 GMT net.EncryptedRpcChannel Send the ack to the server: { T:mtproto.type.Msgs_ack, msg_ids: { T:Vector, type: "Long", list: ["0x57cd3c034448b401"] } }
result TypeObject {
_writeBuffers: null,
_readOffset: 32,
_buffer: <Buffer 19 ca 44 21 91 01 00 00 15 41 55 54 48 5f 4b 45 59 5f 55 4e 52 45 47 49 53 54 45 52 45 44 00 00 f1 75 38 2d>,
_noId: undefined,
_typeId: '19ca4421',
_typeName: 'mtproto.type.Rpc_error',
serialize: [Function: serialize],
deserialize: [Function: deserialize],
__writeError_code: [Function: __writeError_code],
__writeError_message: [Function: __writeError_message],
__readError_code: [Function: __readError_code],
__readError_message: [Function: __readError_message],
error_code: 401,
error_message: 'AUTH_KEY_UNREGISTERED' }
how use that authKey?
if you have singup and get registered authkey please remove createAuthKey method and just use messages.getDialogs when you connected to telegram
hi i try to save authKey in my system and then i use telegramLink.retrieveAuthKey method to get my authKey back and it doesn't get null, it return real authKey and i make new client with this authKey
but when i try to get information like calling 'client.messages.getDialogs' method but print this in terminal:
[INFO] Sun, 28 Aug 2016 22:38:17 GMT net.EncryptedRpcChannel Call of 'mtproto.service.invokeWithLayer' took 1299ms
[INFO] Sun, 28 Aug 2016 22:38:17 GMT net.EncryptedRpcChannel Wrong server_salt in message [0x57c367d88ac07c18]
[INFO] Sun, 28 Aug 2016 22:38:18 GMT net.EncryptedRpcChannel Call of 'mtproto.service.invokeAfterMsg' took 477ms
and stop workingwhy this happens and what can i do?