diff --git a/src/Handler/PlivoHandler.php b/src/Handler/PlivoHandler.php index 0e01085..bf37ca2 100644 --- a/src/Handler/PlivoHandler.php +++ b/src/Handler/PlivoHandler.php @@ -26,13 +26,14 @@ class PlivoHandler extends SMSHandler * @param bool $useSSL Whether to connect via SSL. * @param string $host The Plivo server hostname. * @param string $version The Plivo API version (default PlivoHandler::API_V1) + * @param string $limit The character limit */ - public function __construct($authToken, $authId, $fromNumber, $toNumber, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $host = 'api.plivo.com', $version = self::API_V1) + public function __construct($authToken, $authId, $fromNumber, $toNumber, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $host = 'api.plivo.com', $version = self::API_V1, $limit = 160) { if($version !== self::API_V1){ throw new Exception('API Version \'{$version}\' is not supported!'); } - parent::__construct($authToken, $authId, $fromNumber, $toNumber, $level, $bubble, $useSSL, $host, $version); + parent::__construct($authToken, $authId, $fromNumber, $toNumber, $level, $bubble, $useSSL, $host, $version, $limit); } /** * {@inheritdoc} @@ -42,6 +43,10 @@ public function __construct($authToken, $authId, $fromNumber, $toNumber, $level */ protected function buildContent($record) { + if(strlen($record['formatted']) > $this->limit){ + $record['formatted'] = substr($record['formatted'], 0, $this->limit); + } + $dataArray = array( 'src' => $this->fromNumber, 'dst' => $this->toNumber, diff --git a/src/Handler/SMSHandler.php b/src/Handler/SMSHandler.php index 590b820..a22ccb3 100644 --- a/src/Handler/SMSHandler.php +++ b/src/Handler/SMSHandler.php @@ -50,8 +50,9 @@ abstract class SMSHandler extends SocketHandler * @param bool $useSSL Whether to connect via SSL. * @param string $host The Plivo server hostname. * @param string $version The Plivo API version (default PlivoHandler::API_V1) + * @param string $limit The character limit */ - public function __construct($authToken, $authId, $fromNumber, $toNumber, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $host = 'api.plivo.com', $version = null) + public function __construct($authToken, $authId, $fromNumber, $toNumber, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $host = 'api.plivo.com', $version = null, $limit = 160) { if(empty($version)){ @@ -67,6 +68,7 @@ public function __construct($authToken, $authId, $fromNumber, $toNumber, $level $this->toNumber = $toNumber; $this->host = $host; $this->version = $version; + $this->limit = $limit; } diff --git a/src/Handler/TwilioHandler.php b/src/Handler/TwilioHandler.php index c39c16f..5550ee8 100644 --- a/src/Handler/TwilioHandler.php +++ b/src/Handler/TwilioHandler.php @@ -26,13 +26,14 @@ class TwilioHandler extends SMSHandler * @param bool $useSSL Whether to connect via SSL. * @param string $host The Twilio server hostname. * @param string $version The Twilio API version (default TwilioHandler::API_V1) + * @param string $limit The character limit */ - public function __construct($secret, $sid, $fromNumber, $toNumber, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $host = 'api.twilio.com', $version = self::API_V1) + public function __construct($secret, $sid, $fromNumber, $toNumber, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $host = 'api.twilio.com', $version = self::API_V1, $limit = 160) { if($version !== self::API_V1){ throw new Exception('API Version \'{$version}\' is not supported!'); } - parent::__construct($secret, $sid, $fromNumber, $toNumber, $level, $bubble, $useSSL, $host, $version); + parent::__construct($secret, $sid, $fromNumber, $toNumber, $level, $bubble, $useSSL, $host, $version, $limit); } /** @@ -43,6 +44,10 @@ public function __construct($secret, $sid, $fromNumber, $toNumber, $level = Logg */ protected function buildContent($record) { + if(strlen($record['formatted']) > $this->limit){ + $record['formatted'] = substr($record['formatted'], 0, $this->limit); + } + $dataArray = array( 'From' => $this->fromNumber, 'To' => $this->toNumber,