python - 初始认证 : sending `auth.sendCode` and receiving `msg_container` instead of `auth.SentCode` in python

标签 python authentication telegram

我已经下载了 Telegram ( https://telegram.org/ ) 的 CLI 版本。该 CLI 界面的不完整版本是从以下位置下载的: https://github.com/griganton/telepy

现在身份验证一切正常,但实际功能为 0。

所以我稍微更改了 JASON-Scheme 并添加了初始身份验证所需的功能

{'id': '1988976461',
 'method': 'sendCode',
 'params': [{'name': 'phone_number', 'type': 'string'},
            {'name': 'sms_type', 'type': 'int'},
            {'name': 'api_id', 'type': 'int'},
            {'name': 'api_hash', 'type': 'string'},
            {'name': 'lang_code', 'type': 'string'}],
 'type': 'SentCode'}

如文档中所写 https://core.telegram.org/method/auth.sendCode

现在,在我没有这样做之后,根据文档,似乎在发送一条请求 SMS 代码的消息后,我应该收到 auth.SentCode 数据包开头的十六进制代码 0xEFED51D9,但我收到的是来自服务器的响应,类型为 msg_container73f1f8dc 的内容似乎与我的请求没有任何关联。

总而言之,这一切看起来非常烦人和奇怪,我不知道是什么原因导致了这一切,总而言之,我遵循了文档并尝试按照要求实现。

我发送的数据包看起来很好,我实际上将 SmsCode 发送到我的手机..但我收到的响应很糟糕\由于某种原因不清楚。

我像这样调用在 JSON 中实现的函数:

auth = Session.method_call('sendCode', phone_number=PHONE_NUMBER, sms_type=0, api_id=MY_API_ID, api_hash=MY_API_HASH, lang_code="en")

所以它正在运行..但我需要 phone_code_hash。请注意,出于某种原因,Telegram 本身的文档也很奇怪。查看他们给出的查询示例,数字与文档中所说的不匹配(引用自他们的文档):

查询示例:

(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

取自这里:https://core.telegram.org/method/auth.sendCode

每个部分预期的第一个 DWORD 应该不同.. 例如:768d5f4d 而不是 d16ff372..

那么我错过了什么?

一些引用(出于某种原因,如果我不把它作为代码部分,它不会让我发布它)

https://core.telegram.org/constructor/auth.sentCode
https://core.telegram.org/mtproto/service_messages
https://core.telegram.org/method/auth.sendCode

最佳答案

问题是套接字处理不当..服务器只发送了两个数据包。

第一个数据包是一些Message_Service,第二个数据包是我真正想要的数据..

这很奇怪,因为它没有在文档中说明这些消息

关于python - 初始认证 : sending `auth.sendCode` and receiving `msg_container` instead of `auth.SentCode` in python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29879307/

相关文章:

node.js - Telegraf 和 Heroku 未在 webhook [nodejs] 上发送第一个回复

python - 使用 raw_input 定义要搜索的变量列表

python - 使用 app carnets 将带有 pandas 的文件导入到在 iPad 上运行的 Jupyter Notebook

python - 使用函数重命名文件

spring - 通过 spring LDAP 进行身份验证,并在数据库中进行额外的安全检查

python - python-telegram-bot 中的 SQLite 连接

python - 使用 asyncio 的非阻塞 I/O

facebook - FB auth.logout 在使用 "server-side-workflow"(OAuth 2.0) 登录后被提升

php - 使用数据库 session 登录?

java - Telegram 不能用不同的包名编译