我正在使用Twilio API为WhatsApp设置服务器。当我将媒体文件从WhatsApp发送到Twilio时,它没有显示任何详细信息,而在发送文本时它在正文中显示了详细信息。 发送图像时得到的响应是:
body:
{ SmsMessageSid: 'SM94cXXXX8f8d18a8dbf809cXXXXXXXXXX',
NumMedia: '0',
SmsSid: 'SM94cXXXX8f8d18a8dbf809cXXXXXXXXXX',
SmsStatus: 'received',
Body: '',
To: 'whatsapp:+14XXXXXXXXX',
NumSegments: '1',
MessageSid: 'SM94cXXXX8f8d18a8dbf809cXXXXXXXXXX',
AccountSid: 'ACXXXXXX6f5f98b5adc708d57aedXXXXXX',
From: 'whatsapp:+9199XXXXXXXX',
ApiVersion: '2010-04-01' },
_body: true,
length: undefined,
read: [Function],
route: Route { path: '/sms', stack: [Array], methods: [Object] } },
locals: {},
statusMessage: 'OK',
statusCode: 200,
[Symbol(outHeadersKey)]:
{ 'x-powered-by': [ 'X-Powered-By', 'Express' ],
'content-type': [ 'Content-Type', 'image/jpeg' ] } }
在发送文本时收到的回复是:
body:
{ SmsMessageSid: 'SMd7b60aXXXXXXc830a894c5e91XXXXXXX',
NumMedia: '0',
SmsSid: 'SMd7b60aXXXXXXc830a894c5e91XXXXXXX',
SmsStatus: 'received',
Body: 'Hello',
To: 'whatsapp:+14XXXXXXXXX',
NumSegments: '1',
MessageSid: 'SMd7b60aXXXXXXc830a894c5e91XXXXXXX',
AccountSid: 'ACXXXXXX6f5f98b5adc708d57aedXXXXXX',
From: 'whatsapp:+91XXXXXXXXXX',
ApiVersion: '2010-04-01' }
使用的代码是:
const http = require('http');
const express = require('express');
const accountSid = 'XXXXXXXX';
const authToken = 'XXXXXXXX';
const client = require('twilio')(accountSid, authToken);
const MessagingResponse = require('twilio').twiml.MessagingResponse;
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.post("/sms",function(req,res){
rt(req,res);
});
function rt (req,res){
res.writeHead(200, {'Content-Type': 'image/jpeg'});
console.log(res);
}
http.createServer(app).listen(1337, () => {
console.log('Express server listening on port 1337');
});
请提供帮助如何从响应中获取有关图像的详细信息。
答案 0 :(得分:1)
这里是Twilio开发人员的传播者。
此刻,WhatsApp消息中的Twilio does not support incoming media。此支持正在开发中,应尽快退出。