Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions NexmoMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
*
*
*
*/

Expand Down Expand Up @@ -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') ) {
Expand Down Expand Up @@ -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 );

}
Expand Down Expand Up @@ -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;
Expand Down