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?

图片转代码服务由CSDN问答提供 功能建议

我正在使用Twilio 发送短信,如下所示(代码的相关部分):

  require('Twilio。  PHP');  
 $ body =“一些示例邮件正文”; 
 $ 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,
)); 
   
 
 

以上工作正常,但是,如果我将其更改为:

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

邮件正文返回“0”。

我也尝试过:

  $ myMessage =“some example”+ $ test +“message body text”; 
   
 
  

然后:

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

但这会产生相同的结果 ( “0”)。 请注意:

  $ myMessage =“一些示例邮件正文”; 
   
 
 

此工作正常( 即,没有变量的同样的东西)

我在这里缺少什么?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题