使用 Twilio 在 Php 中发送超过 160 个字符的短信
Send SMS of more than 160 characters in Php using Twilio
我用过 twilio yii 扩展。
http://www.yiiframework.com/extension/twiliosms/
但不能发送超过 160 个字符的消息。
它会产生这个错误。
邮件正文超过了 160 个字符的限制。
[*:status] => 400
[*:info] => 'https://www.twilio.com/docs/errors/21605'
[*:message] => 'The message body exceeds the 160 character limit.'
[Exception:string] => ''
[*:code] => 21605
[*:file] => '/home/nailspolished/public_html/protected/extensions/twilio/Services/Twilio.php'
[*:line] => 1064
[Exception:trace] => array
(
0 => array
(
'file' => '/home/nailspolished/public_html/protected/extensions/twilio/Services/Twilio.php'
'line' => 1035
'function' => '_processResponse'
'class' => 'Services_Twilio'
'type' => '->'
'args' => array
(
0 => array
(
0 => 400
1 => array
(
'Access-Control-Allow-Credentials' => 'true'
'Access-Control-Allow-Headers' => 'Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since'
'Access-Control-Allow-Methods' => 'GET, POST, DELETE, OPTIONS'
'Access-Control-Allow-Origin' => '*'
'Access-Control-Expose-Headers' => 'ETag'
'Content-Type' => 'application/json; charset=utf-8'
'Date' => 'Tue, 02 Jun 2015 10:57:46 GMT'
'X-Powered-By' => 'AT-5000'
'X-Shenanigans' => 'none'
'Content-Length' => '151'
'Connection' => 'keep-alive'
)
2 => '{\"code\": 21605, \"message\": \"The message body exceeds the 160 character limit.\", \"more_info\": \"https://www.twilio.com/docs/errors/21605\", \"status\": 400}'
)
)
)
Twilio APi 调用代码为:-
require_once(dirname(__FILE__) . '/../extensions/twilio/Services/Twilio.php');
$sid = "******************";
$token = "******************";
$client = new Services_Twilio($sid, $token);
$message = $client->account->sms_messages->create(
Yii::app()->params['fromNumber'], // From
Yii::app()->params['countryCode'] . $value['upa_phone_no'], // To
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
);
排序邮件发送正常,但长邮件出错。
我知道我们可以发送超过 160 条消息,但我不知道如何发送消息。
您使用的是旧版本的 twilio。使用这个 yii 扩展,它是 twilio yii 扩展的最新版本。
我用过 twilio yii 扩展。
http://www.yiiframework.com/extension/twiliosms/
但不能发送超过 160 个字符的消息。 它会产生这个错误。
邮件正文超过了 160 个字符的限制。
[*:status] => 400
[*:info] => 'https://www.twilio.com/docs/errors/21605'
[*:message] => 'The message body exceeds the 160 character limit.'
[Exception:string] => ''
[*:code] => 21605
[*:file] => '/home/nailspolished/public_html/protected/extensions/twilio/Services/Twilio.php'
[*:line] => 1064
[Exception:trace] => array
(
0 => array
(
'file' => '/home/nailspolished/public_html/protected/extensions/twilio/Services/Twilio.php'
'line' => 1035
'function' => '_processResponse'
'class' => 'Services_Twilio'
'type' => '->'
'args' => array
(
0 => array
(
0 => 400
1 => array
(
'Access-Control-Allow-Credentials' => 'true'
'Access-Control-Allow-Headers' => 'Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since'
'Access-Control-Allow-Methods' => 'GET, POST, DELETE, OPTIONS'
'Access-Control-Allow-Origin' => '*'
'Access-Control-Expose-Headers' => 'ETag'
'Content-Type' => 'application/json; charset=utf-8'
'Date' => 'Tue, 02 Jun 2015 10:57:46 GMT'
'X-Powered-By' => 'AT-5000'
'X-Shenanigans' => 'none'
'Content-Length' => '151'
'Connection' => 'keep-alive'
)
2 => '{\"code\": 21605, \"message\": \"The message body exceeds the 160 character limit.\", \"more_info\": \"https://www.twilio.com/docs/errors/21605\", \"status\": 400}'
)
)
)
Twilio APi 调用代码为:-
require_once(dirname(__FILE__) . '/../extensions/twilio/Services/Twilio.php');
$sid = "******************";
$token = "******************";
$client = new Services_Twilio($sid, $token);
$message = $client->account->sms_messages->create(
Yii::app()->params['fromNumber'], // From
Yii::app()->params['countryCode'] . $value['upa_phone_no'], // To
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
);
排序邮件发送正常,但长邮件出错。 我知道我们可以发送超过 160 条消息,但我不知道如何发送消息。
您使用的是旧版本的 twilio。使用这个 yii 扩展,它是 twilio yii 扩展的最新版本。