Twillio 回复消息 [英] Twillio reply to message

查看:34
本文介绍了Twillio 回复消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码:

require dirname(__FILE__)."/twilio/services/Twilio.php"; 
$client = new Services_Twilio($option['twilioAccountSid'], $option['twilioAuthToken']); 

$client->account->sms_messages->create($option['twilioFrom'], 
    $to, 
    'Will you attend?',
    array('StatusCallback'=>'http://domain.com/callback.php'));

回调.php:

file_put_contents('/twilio.log', print_r(array($_REQUEST), true) . PHP_EOL );

场景如下.我发送消息你会参加吗?"$ 至 +155555555.当他们回复时,我想将该答案插入到数据库中.

The scenario is the following. I send the message "Will you attend?" $to +155555555. When they reply back, I want to insert that answer into a database.

我认为 callback.php 会在他们回复消息时被调用,我会将变量 $_REQUEST['body'] 与他们的答案以及其他变量一起使用,但事实并非如此.在 twilio.log 中,我只有确认我发送了消息.

I thought that callback.php will be called when they reply with a message, and I'll have the variable $_REQUEST['body'] with their answer, along with other variables, but that's not the case. In twilio.log I have only a confirmation that I sent the message.

如何将响应消息抓取到一个 php 文件中以便以后与数据库一起使用?

推荐答案

https://www.twilio.com/user/account/phone-numbers/ 选择您使用的号码.查看消息旁边的请求网址.你必须把你的回调放在那里,它会起作用.

https://www.twilio.com/user/account/phone-numbers/ Select the number you use. Look next to Messaging for Request URL . There you have to put your callback and it will work.

这篇关于Twillio 回复消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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