如何在WordPress PHP Twilio中用MMS回复入站短信



使用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开发人员的传道者。

要使用媒体进行响应,您需要在<Message>中嵌套<Media><Body>元素。<Media>应该有一个指向要回复的媒体的URL。

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>');
}

如果这有帮助,请告诉我。

最新更新