如何使用 Nodejs 通过 Twilo 将 Pdf 作为彩信发送? [英] How to Send Pdf as MMS by Twilo Using Nodejs?

查看:29
本文介绍了如何使用 Nodejs 通过 Twilo 将 Pdf 作为彩信发送?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个测试 Twilio 号码,可以发送短信、彩信、语音电话.我成功发送短信和语音电话.

I have a Test Twilio Number which is capable to send SMS,MMS,Voice Call . I am Successful in sending SMS and Voice call .

我面临将 PDF 作为 MMS 发送的挑战.根据 TwilioDocs Accepted-mime-types PDF 是受支持的类型.

I am facing a challenge to send PDF as MMS .. As per the TwilioDocs Accepted-mime-types PDF is a Supported Type.

当我尝试使用语法发送时:-

While am trying to Send by using the Syntax :-

var accountSid = '<accountSid >';   
var authToken = '<authToken>';       
var client = require('twilio')(accountSid, authToken);
         client.messages.create({
            to: "<validnum>",
            from: "<validFrom>",  
            body: "Test Message ",
            mediaUrl: "http://docdro.id/GAak2pV"
            mediaContentType:"pdf"
        }, function(err, message) {
            if(err){
                console.log('Error Alert For Message '+JSON.stringify(err));
            }else{
                console.log(message.sid);
            }
        });

使用上述代码,我可以发送 JPG/PNG,但 PDF 因错误而失败:-

With the Above Code i can able to send JPG/PNG but PDF is being Failed by an Error:-

(Error: 30008) Unknown error. None

我完全不知道!!有人帮我提出储蓄建议谢谢,普拉萨德.

I have no clue Totally !! Somebody help me with a Saving Suggestion Thanks, Prasad.

推荐答案

Twilio 开发人员布道者在这里.

Twilio developer evangelist here.

正如 Andy 在评论中指出的,您使用的 DropBox 的 URL 实际上指向包含您的 PDF 的 HTML 页面.您需要直接链接到 PDF 文件本身,Twilio 不会在页面内发现 PDF 文件.

As Andy is pointing out in the comments, the URL to DropBox that you are using is actually pointing towards an HTML page that contains your PDF. You need the direct link to the PDF file itself, Twilio does not do any work to discover the PDF file within pages.

如果您可以在 S3 或其他任何地方公开托管该文件,那么您自己会更幸运.

If you can host the file on S3, or anywhere else publicly, yourself then you will have more luck with this.

这篇关于如何使用 Nodejs 通过 Twilo 将 Pdf 作为彩信发送?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆