Viber REST API,如何找到唯一的 Viber 用户 ID?
Viber REST API, how to find Unique Viber user id?
资源URLhttps://chatapi.viber.com/pa/send_message
一般发送消息参数
我正在尝试从 Postman 向 viber 发送消息。我不知道如何找到唯一的 Viber 用户 ID,该参数是必需的。
我收到这个错误:
{"status":999,"status_message":"Bad receiver ID","message_token":5126721184521938239}
Danny Dainton 提到了关于如何获取数据的文档,包括关于您自己帐户的唯一 ID,而不是关于其他人的!
如果用户订阅了您的 public 帐户,您将收到包含用户唯一 ID 的回调到您的 webhook,只有这样您才能向该用户发送消息。
根据 viber 文档:
The send_message API allows accounts to send messages to Viber users who subscribe to the account. Sending a message to a user will be possible only after the user has subscribed to the Public Account by pressing the subscribe button or by sending a message, or by sending a message to a bot (see subscribed callback for additional information).
非常重要
Before an account can send messages to a user, the user will need to
subscribe to the account. Subscribing can take place in one of two
ways:
User sends message to the account (both Public Accounts and bots)
when a user sends its first message to a account the user will be
automatically subscribed to the account. Sending the first message
will not trigger a subscribe callback, only a message callback (see
receive message from user section). Subscribed event is sent to the
Public Account (Public Accounts only)
user clicks a subscribe button
which triggers the subscribe callback as described below.
简单,只需调用获取帐户信息API,其资源URL是https://chatapi.viber.com/pa/get_account_info
您将在响应中找到所有订阅者的列表及其用户 ID。请注意,每个 public 帐户的每个用户的这些用户 ID 都是唯一的。
更正:获取帐户信息 API 似乎没有 return 所有订阅者,它只是 return 为我编辑了我的用户 ID([=17 的管理员=] 帐户)。基于此,除了新订阅者的回调、消息等之外,无法获取订阅者的用户 ID。
通常您应该从所有回调中收集 Viber ID 并存储在数据库中以备将来使用。但是,如果您错过了该步骤,您可以通过定期调用 get_online endpoint and then use get_user_details 端点来收集在线订阅用户的 Viber ID,以获取有关未知用户的更多信息。
资源URLhttps://chatapi.viber.com/pa/send_message
一般发送消息参数
我正在尝试从 Postman 向 viber 发送消息。我不知道如何找到唯一的 Viber 用户 ID,该参数是必需的。
我收到这个错误:
{"status":999,"status_message":"Bad receiver ID","message_token":5126721184521938239}
Danny Dainton 提到了关于如何获取数据的文档,包括关于您自己帐户的唯一 ID,而不是关于其他人的!
如果用户订阅了您的 public 帐户,您将收到包含用户唯一 ID 的回调到您的 webhook,只有这样您才能向该用户发送消息。
根据 viber 文档:
The send_message API allows accounts to send messages to Viber users who subscribe to the account. Sending a message to a user will be possible only after the user has subscribed to the Public Account by pressing the subscribe button or by sending a message, or by sending a message to a bot (see subscribed callback for additional information).
非常重要
Before an account can send messages to a user, the user will need to subscribe to the account. Subscribing can take place in one of two ways:
User sends message to the account (both Public Accounts and bots)
when a user sends its first message to a account the user will be automatically subscribed to the account. Sending the first message will not trigger a subscribe callback, only a message callback (see receive message from user section). Subscribed event is sent to the Public Account (Public Accounts only)
user clicks a subscribe button which triggers the subscribe callback as described below.
简单,只需调用获取帐户信息API,其资源URL是https://chatapi.viber.com/pa/get_account_info 您将在响应中找到所有订阅者的列表及其用户 ID。请注意,每个 public 帐户的每个用户的这些用户 ID 都是唯一的。
更正:获取帐户信息 API 似乎没有 return 所有订阅者,它只是 return 为我编辑了我的用户 ID([=17 的管理员=] 帐户)。基于此,除了新订阅者的回调、消息等之外,无法获取订阅者的用户 ID。
通常您应该从所有回调中收集 Viber ID 并存储在数据库中以备将来使用。但是,如果您错过了该步骤,您可以通过定期调用 get_online endpoint and then use get_user_details 端点来收集在线订阅用户的 Viber ID,以获取有关未知用户的更多信息。