doudiemei2013 2016-07-25 13:41
浏览 330
已采纳

使用Twilio发送动态SMS消息正文

I'm using Twilio to send an SMS message like so (relevant part of code shown):

require('Twilio.php'); 
$body ="some example message body text";
$account_sid = 'XXXXXXX'; 
$auth_token = 'YYYYY'; 
$client = new Services_Twilio($account_sid, $auth_token); 
$client->account->messages->create(array(  
    'To' => $phone,
    'From' => "+15132592073", 
    'Body' => $body,   
));

The above works fine, however, if I change this to:

'Body' => "some example "+$test+" message body text";

The message body returns as "0".

I've also tried:

$myMessage ="some example "+$test+" message body text";

and then:

$client->account->messages->create(array(  
        'To' => $phone,
        'From' => "+15132592073", 
        'Body' => $myMessage,   
    ));

But this yields the same result ("0"). Note that:

$myMessage ="some example message body text";

this works fine also (i.e., same thing without the variable)

What am I missing here?

  • 写回答

1条回答 默认 最新

  • douzhangjian1505 2016-07-25 13:44
    关注

    You should use:

    $body = "some example ". $test . " message body text";
    

    Notice the concatenation operator '.' and not '+'.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测