python - 如何在 python 中使用 twilio api 将本地文件作为传真发送?
问题描述
我是 twilio 和 python 的新手。我想使用 twilio api 构建一个简单的传真命令。所以我使用它,它工作得很好
fax = client.fax.faxes \
.create(
from_="+18566198960",
media_url="https://www.twilio.com/docs/documents/25/justthefaxmaam.pdf",
to="+14105210871"
)
print(fax.sid)
但是,我想将 media_url 更改为位于 doc 文件夹中的本地文件,所以我使用这个 media_url
media_url="../doc/testfax.doc"
但我得到这个错误
HTTP 错误您的请求是:
邮寄/传真
Twilio 返回以下信息:
无法创建记录:参数“MediaUrl”无效
更多信息可在此处获得:
如何分配本地文件作为要发送的传真内容?
解决方案
我查看了用于发送传真的 Twilio API - https://www.twilio.com/docs/fax/send
这个需要:
* A destination phone number or SIP URI.
* A From number - this can be either an Incoming Phone Number or an Outgoing Caller ID. (Optional for SIP destinations.)
* A URL which points to the media that will be sent via fax (currently, this must be a PDF file; see our security page for information on how to ensure the request for your media comes from Twilio).
API 不支持本地文件(只有 URL,带有 PDF 文件)。
推荐阅读
- python - python多处理中守护进程的目的是什么?
- angular - Angular 和纱线工作区:TS 编译时缺少文件
- opencv - 如何在同一图像上找到两点的长度
- javascript - 如何将相同的值分配给一行中的两个变量
- ldap - 多个地点和部门的 LDAP 过滤器查询
- typescript - 该函数应返回一个对象,该对象具有 key 作为参数 someKey 和 value 作为 someValue
- python - 如何在python中堆叠2个不同长度的numpy数组
- html - 如何制作(最)基本的 .htaccess 文件来密码保护网站
- java - 如何在 RecyclerView 中选择单个项目?
- google-sheets - 根据左侧单元格的条件对单元格求和