如何在python中使用twilio api将本地文件作为传真发送?

问题描述 投票:0回答:1

我是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错误您的请求是:

POST /传真

Twilio返回了以下信息:

无法创建记录:参数“MediaUrl”无效

更多信息可在此处获得:

https://www.twilio.com/docs/errors/20001

如何将本地文件指定为要发送的传真内容?

python twilio fax
1个回答
0
投票

我查看了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不支持本地文件(仅包含带有PDF文件的URL)。

© www.soinside.com 2019 - 2024. All rights reserved.