![](/img/trans.png)
[英]How do you receive Whatsapp messages from Twilio using Node.JS?
[英]how to send locally stored media files using twilio over whatsapp .. node js express
我需要將生成的 PDF 作為 whatsapp 消息發送,但是當我嘗試讀取文件時它顯示錯誤。
easyinvoice.createInvoice(data, function(result) {
//The response will contain a base64 encoded PDF file
fs.writeFileSync("invoice.pdf", result.pdf, 'base64');
var s = result.pdf;
client.messages
.create({
mediaUrl: s,
body: 'invoice',
from: 'whatsapp:+somenumber',
to: 'whatsapp:+somenumber'
})
.then(message => console.log(message.sid))
.done();
});
米德拉傑,你好。 Twilio 開發人員布道師在這里。
您不能使用本地路徑,因為媒體 url 必須可供 Twilio 的服務器公開訪問(即它必須具有 URL),以便可以檢索資產並將其添加到消息中。 如果接受本地路徑,它將指向隨機 Twilio 服務器上的“/Users/Name/file.gif”。
您可以使用Twilio 資產發送本地文件。 您也可以使用 Ngrok.com 將本地 Web 服務器公開到 Internet,使用 ngrok 托管文件並在外部共享本地文件。
讓我知道這是否有幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.