如何使用Telegram API代码?

4

我在https://my.telegram.org/apps注册,并获得了api_hash、api_id和public key,现在我想使用这个函数:https://core.telegram.org/method/auth.sendCode

auth.sentCode#efed51d9 phone_registered:Bool phone_code_hash:string send_call_timeout:int is_password:Bool = auth.SentCode;
auth.sentAppCode#e325edcf phone_registered:Bool phone_code_hash:string send_call_timeout:int is_password:Bool = auth.SentCode;
---functions---
auth.sendCode#768d5f4d phone_number:string sms_type:int api_id:int api_hash:string lang_code:string = auth.SentCode;

查询示例

(auth.sendCode "79991234567" 1 32 "test-hash" "en")
=
(auth.sentCode
  phone_registered:(boolFalse)
  phone_code_hash:"2dc02d2cda9e615c84"
)

d16ff372 3939370b 33323139 37363534 00000001 00000020 73657409 61682d74 00006873 e77e812d
=
2215bcbd bc799737 63643212 32643230 39616463 35313665 00343863 e12b7901

我该如何使用这个查询示例?还有这个二进制文件是什么意思?“d16ff372 3939370b 33323139 ...."

开始生成你的 AuthKey。请参考我下面的答案。 - Charles Okwuagwu
2个回答

2
您不能直接开始向Telegram发送查询。创建api_hash和api_id是开始使用Telegram API的基本步骤。希望您知道Telegram使用自己的协议称为'MTProto'。您可以在Telegram官方网站上获得详细的描述。
根据Telegram协议,客户端和服务器使用Diffie-Hellman算法共享'Authorization Key'(用于加密和解密)。请参见示例https://core.telegram.org/mtproto/samples-auth_key。成功创建授权密钥后,我们可以开始调用Telegram API,这称为RPC查询。
您还可以参考https://github.com/ex3ndr/telegram-api进行实现。
示例中的十六进制数据只是按照算法生成的查询。

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接