doudiemei2013 2016-07-25 13: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 13:44
    关注

    You should use:

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

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

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

报告相同问题?