You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Vonage API动态设置接收SMS的Webhook地址?

设置Vonage API SMS接收Webhook的动态方法

你可以通过Vonage的Numbers API实现动态更新号码的SMS Webhook配置,逻辑和你用Twilio/SignalWire的方式类似,核心是调用号码更新接口。

核心步骤:

  • 先获取目标号码的基础信息(包括号码本身和所属国家代码)
  • 调用号码更新接口,指定接收SMS的Webhook地址和请求方法

Python代码示例:

import vonage

# 初始化Vonage客户端
client = vonage.Client(key="你的Vonage密钥", secret="你的Vonage密码")
numbers_client = vonage.Numbers(client)

# 获取目标号码(这里取账号下第一个号码,也可通过number参数指定具体号码)
account_numbers = numbers_client.get_account_numbers(limit=1)
target_number_info = account_numbers["numbers"][0]

# 更新SMS Webhook配置
update_response = numbers_client.update_number(
    msisdn=target_number_info["msisdn"],
    country=target_number_info["country"],
    mo_http_url="你的Webhook地址",
    mo_http_method="GET"  # 可选,默认请求方法为POST
)

print(update_response)

关键参数说明:

  • msisdn:需要更新的Vonage号码(需带国家码,例如+1234567890)
  • country:号码所属国家的两位代码(例如US)
  • mo_http_url:接收SMS的Webhook地址
  • mo_http_method:Webhook的请求方法,支持GET或POST

内容的提问来源于stack exchange,提问作者coderforlife

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 14:47:03