问题描述
使用WordPress PHP和Twilio,我如何用包含媒体的消息回复入站SMS。具体来说,我想用图像回复入站邮件。我在寻找一种将媒体添加到响应中的方法时遇到了麻烦。如何将图像添加为以下使用的格式?
function trigger_receive_sms($request) {
echo header('content-type: text/xml');
echo ('<?xml version="1.0" encoding="UTF-8"?>');
echo ('<Response>');
echo ('<Message>Hello there,did you get the image?</Message>');
echo ('</Response>');
}
将本指南用于总体基础:https://www.twilio.com/blog/2017/09/receive-sms-wordpress-php-plugin.html
解决方法
这里是Twilio开发人员的传播者。
要用媒体回应,您需要nest <Media>
and <Body>
elements in your <Message>
。 <Media>
的网址应为您要回复的媒体。
function trigger_receive_sms($request) {
echo header('content-type: text/xml');
echo ('<?xml version="1.0" encoding="UTF-8"?>');
echo ('<Response>');
echo (' <Message>');
echo (' <Body>Hello there,did you get the image?</Body>');
echo (' <Media>https://demo.twilio.com/owl.png</Media>');
echo (' </Message>');
echo ('</Response>');
}
让我知道是否有帮助。