doudiemei2013 2016-07-25 05:41
浏览 331
已采纳

使用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 05:44
    关注

    You should use:

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

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

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

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部