diff --git a/NexmoMessage.php b/NexmoMessage.php index aa63d56..50b8fce 100644 --- a/NexmoMessage.php +++ b/NexmoMessage.php @@ -2,17 +2,17 @@ /** * Class NexmoMessage handles the methods and properties of sending an SMS message. - * + * * Usage: $var = new NexoMessage ( $account_key, $account_password ); * Methods: * sendText ( $to, $from, $message, $unicode = null ) * sendBinary ( $to, $from, $body, $udh ) * pushWap ( $to, $from, $title, $url, $validity = 172800000 ) * displayOverview( $nexmo_response=null ) - * + * * inboundText ( $data=null ) * reply ( $text ) - * + * * */ @@ -70,7 +70,7 @@ function NexmoMessage ($api_key, $api_secret) { * message type. Otherwise set to TRUE if you require * unicode characters. */ - function sendText ( $to, $from, $message, $unicode=null ) { + function sendText ( $to, $from, $message, $unicode=null, $options = array() ) { // Making sure strings are UTF-8 encoded if ( !is_numeric($from) && !mb_check_encoding($from, 'UTF-8') ) { @@ -103,6 +103,12 @@ function sendText ( $to, $from, $message, $unicode=null ) { 'text' => $message, 'type' => $containsUnicode ? 'unicode' : 'text' ); + + // Insert extra options + foreach($options as $option => $value) { + $post[$option] = $value; + } + return $this->sendRequest ( $post ); } @@ -226,7 +232,8 @@ private function nexmoParse ( $from_nexmo ) { $response_obj->cost = $total_cost = 0; if (is_array($response_obj->messages)) { foreach ($response_obj->messages as $msg) { - $total_cost = $total_cost + (float)$msg->messageprice; + if(property_exists($msg, "messageprice")) + $total_cost = $total_cost + (float)$msg->messageprice; } $response_obj->cost = $total_cost;