duanchu2607 2016-03-13 22:50
浏览 75

Twilio API:将SMS日志数据推送到网页

I'm working on a project where we need to have a history of incoming text messages dumped to a webpage. I have begun using the Twilio REST API and php library to grab the SMS log data. I'm currently hitting an issue where I'm not able to grab the date sent, however. According to Twilio, I should be able to echo the DateSent property. Currently only body and from are currently working for me.

My php:

<?php
// this line loads the library
require('xxxx/twilio-php/Services/Twilio.php');

$account_sid = 'xxxxxxxxxxxxxxxxxxxxxxxxxx';
$auth_token = 'xxxxxxxxxxxxxxxxxxxxxxxxxx';
$client = new Services_Twilio($account_sid, $auth_token);

$messages = $client->account->messages->getIterator(0, 50, array(
));

foreach ($messages as $message) {
echo $message->body;
echo $message->DateSent;
echo $message->from;
}

Any idea on getting the information I'm seeking to display?

Using js to load this into my webpage and dynamically refresh.

Thank you!

  • 写回答

1条回答 默认 最新

  • dongshuobei1037 2016-03-14 13:08
    关注

    Twilio developer evangelist here.

    The library actually converts the properties that the API sends into more PHP-like properties. So, instead of using $message->DateSent you can use $message->date_sent.

    Give that a go and let me know if it helps.

    评论

报告相同问题?

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划