python - 为什么在 telegram 中调用 auth.signIn 时会收到 PHONE_NUMBER_UNOCCUPIED 错误?

标签 python api telegram

我已经发送了 auth.sendCode 方法,响应如下:

('sentCode: ', {u'req_msg_id': 6324698204597889024L, u'result': {u'type': {u'len
gth': 5}, u'phone_registered': False, u'flags': 6, u'timeout': 120, u'next_type'
: {}, u'phone_code_hash': '52eb4ab096ea211b52'}})

这是使用 Telegram 测试服务器。我已成功在 telegram iPhone 应用程序和桌面应用程序中使用相同的电话号码,因此我知道该电话号码在生产中有效。 (它在测试服务器上也应该有效吗?)

当我使用 auth.signIn 遵循 auth.sendCode 时,我收到以下错误响应:

('authorization: ', {u'error_message': 'PHONE_NUMBER_UNOCCUPIED', u'error_code':
 400})

这两种方法之间是否有注册电话号码的步骤?

最佳答案

来自 https://core.telegram.org/api/auth

The auth.sendCode method will also return the phone_registered field, which indicates whether or not the user with this phone number is registered in the system. If phone_registered == boolTrue, authorization requires that auth.signIn be invoked. Otherwise, basic information must be requested from the user and the new user registration method (auth.signUp) must be invoked.

When phone_registered === boolFalse, the auth.signIn method can be used to pre-validate the code entered from the text message. The code was entered correctly if the method returns Error 400 PHONE_NUMBER_UNOCCUPIED.

关于python - 为什么在 telegram 中调用 auth.signIn 时会收到 PHONE_NUMBER_UNOCCUPIED 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39236105/

相关文章:

api - 如何构建自动完成 API?

api - 在 Telegram API 中获取具有聊天链接的 chat_id

python - 将格式化字符串从 % 更改为替代字符?

python - 有什么方法可以将变量传递给 django 元类?

python - 从文本文件中检索单个整数并将其分配给变量

php - 如何限制API访问受限域名?

python - 查找一组经过过滤的组合的算法

python /数巴 : Trouble creating custom type using Numba Extension API

python - Telegram Bot API : how to list all active users

android - Telegram 发送未保存的联系人