访问 Twilio MMS 图像 [英] Accessing Twilio MMS images

查看:26
本文介绍了访问 Twilio MMS 图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Twilio 中,当给出 ImageMedia URL 时,它正在访问 twilio api,如下所示

In Twilio when the ImageMedia URL is given it is accessing the twilio api as follows

https://api.twilio.com/2010-04-01/Accounts/{account sid}/Messages/{message sid}/Media/{media sid}

https://api.twilio.com/2010-04-01/Accounts/{account sid}/Messages/{message sid}/Media/{media sid}

如果您已手动登录 twilio API,该 url 重定向到位于

If you have manually logged into the twilio API that url redirects to the image located at

http://media.twiliocdn.com.s3-website-us-east-1.amazonaws.com/{account sid}/{image id}

http://media.twiliocdn.com.s3-website-us-east-1.amazonaws.com/{account sid}/{image id}

如何从 twilio API 获取直接图像 ID 以包含在我的网络应用程序中?

How can I get the direct image ID from the twilio API to include in my web app?

我正在使用 node.js,每次我尝试轮询媒体资源时,我收到的只是指向 api.twilio.com 而不是 mdeia.twiliocdn.com 的链接

I am working with node.js and every time I try to poll the media resources all I receive is the link to the api.twilio.com and not the mdeia.twiliocdn.com

推荐答案

图书馆不处理这个我能找到的功能

The library doesn't handle this feature that I can find

但是,如果其他人遇到同样的问题,这里是解决方案

However, if anyone else comes across the same problem here is the solution

安装请求.

然后只需获取 NumMediaMediaUrl 参数...

Then just get NumMedia and MediaUrl parameters...

if(req.body.NumMedia > 0){ 
   var request = require('request')
    request.get(req.body.MediaUrl0).auth(config.twilio.sid, config.twilio.auth, false).pipe(fs.createWriteStream("/var/www/app/public/mms/" + sid + '1.jpg' ));
 }

请记住,最多可以发送 10 张图像,因此您只需要逻辑来收集这些额外的图像.

Remember that up to 10 images can be sent so you would just need the logic too gather those extra images.

这篇关于访问 Twilio MMS 图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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