MBSLib
[ class tree: MBSLib ] [ index: MBSLib ] [ all elements ]

Class: SMSComm

Source Location: /lib/SMSComm.class.php

Class Overview


SMSComm SMS sending API client:


Author(s):

Methods



Class Details

[line 48]
SMSComm SMS sending API client:

  • SMS, WapPush sending
  • SMS delivery reports
  • mass SMS packet sending
  • mass SMS delivery monitoring
  • schedule (delay) SMS for later date




Tags:

tutorial:  Zend Framework connection example:
tutorial:  Simple connection example:
author:  Mantas Litvaitis <ml@vero.lt>
author:  Valdas Petrulis <vpe@vero.lt>


[ Top ]


Class Methods


constructor __construct [line 98]

SMSComm __construct( [string $username = null], [string $password = null])

Object constructor



Parameters:

string   $username   SMSComm username. Optional. Can be set later
string   $password   SMSComm password. Optional. Can be set later

[ Top ]

method delete [line 637]

int delete( [string $ident = null], [int|array $messageId = null], [string|array $phones = null])

Dedicated to unrecoverably remove unsent messages (one or overal packet).

At least one search parameter is required.




Tags:

return:  Amount of deleted messages
throws:  SMSCommTransportException
throws:  SMSCommException
access:  public


Parameters:

string   $ident   (Optional) Indicate which messages to delete, by external system unique identifier e.g. mass message identifier
int|array   $messageId   (Optional) Indicate which messages to delete, by unique MBS identifier or array of them
string|array   $phones   (Optional) Phones to be deleted

[ Top ]

method edit [line 570]

array edit( [string $ident = null], [int|array $messageId = null], [string $sender = null], [string $message = null], [string $url = null], [string $newIdent = null], [string $type = null], [string $sendDate = null], [string $dlrUrl = null], [string $priority = null], [string $charset = null], [int $serviceId = null], [int $partnerId = null])

Dedicated to edit unsent messages (one or overal packet).

At least one search parameter is required. At least one update parameter is required.




Tags:

return:  

Messages successfully edited: array( 'status' => 'success', 'data' => array( 'edited' => 125, // amount of edited messages ), )

Messages was not edited because of wrong data data given: array( 'status' => 'fail', 'data' => array( 'field' => 'message', // which field contains error 'field_error' => 'Empty sending text', // error description ) )

throws:  SMSCommTransportException
throws:  SMSCommException
access:  public


Parameters:

string   $ident   (Optional) Indicate which messages to edit, by external system unique identifier e.g. mass message identifier
int|array   $messageId   (Optional) Indicate which messages to edit, by unique MBS identifier or array of them
string   $sender   (Optional) If want to edit sender phone number
string   $message   (Optional) If want to edit SMS text to be sent (in case of WapPush, the text is the link heading)
string   $url   (Optional) If want to edit a link of WapPush to be sent
string   $newIdent   (Optional) If want to edit external system unique identifier e.g. edited messages can be formed to a new packet
string   $type   (Optional) If want to edit type of sending (SMS, WapPush)
string   $sendDate   (Optional) If want to edit message sending date
string   $dlrUrl   (Optional) If want to edit URL address, whereto the SMS delivery results should be sent
string   $priority   (Optional) If want to edit message priority
string   $charset   (Optional) If want to edit sending text rule (charset)
int   $serviceId   (Optional) If want to edit MBS service ID
int   $partnerId   (Optional) If want to edit partner ID

[ Top ]

method getDebug [line 861]

bool getDebug( $state)

Returns debug status (on/off)



Tags:

return:  debug status
access:  public


Parameters:

   $state  

[ Top ]

method getDebugBuffer [line 902]

string getDebugBuffer( )

Get debug output buffer content



Tags:

access:  public


[ Top ]

method getDebugType [line 892]

string getDebugType( )

Get debug type



Tags:

return:  Possible values 'echo', 'buffer'
access:  public


[ Top ]

method getPacket [line 516]

array getPacket( string $ident)

Dedicated to retrieve mass message sending, delivery statistics



Tags:

return:  Mass message information structure: array( 'ident' => 'news-reminder-12346', // external system identifier of messages 'stats_overal' => 10, // amount of total messages 'stats_sent' => 4, // amount of already sent messages 'stats_delivered' => 2, // amount of messages delivered to users 'stats_length' => 11, // amount of chunks to be paid (1 packet contains 160 characters) )
throws:  SMSCommTransportException
throws:  SMSCommException
access:  public


Parameters:

string   $ident   Indicate which messages to retrieve, by external system unique identifier e.g. mass message identifier

[ Top ]

method send [line 266]

array send( string $sender, string $phone, string $message, [string $url = null], [string $ident = null], [string $type = 'SMS'], [string $operator = null], [string $sendDate = null], [string $dlrUrl = null], [string $priority = null], [string $charset = null], [int $serviceId = null], [int $partnerId = null])

Send single message



Tags:

return:  

On successful send: array( 'status' => 'success', 'data' => array( 'id' => '111' ), )

On validation error: array( 'status' => 'fail', 'data' => array( 'field_error' => 'Wrong msisdn format', ) )

throws:  SMSCommTransportException
throws:  SMSCommException
access:  public


Parameters:

string   $sender   Sender phone number. This function is turned on by individual agreement, then all possible values should be listed
string   $phone   Receiver’s telephone number (MSISDN) in the international format "370xxxyyyyy"
string   $message   SMS text to be sent (in case of WapPush, the text is the link heading)
string   $url   (Optional) In case of WapPush, a link of WapPush to be sent
string   $ident   (Optional) External system unique identifier e.g. published advertisment unique number
string   $type   (Optional) Type of sending (SMS, WapPush), by default SMS
string   $operator   (Optional) To be indicated only if the partner knows the recipient’s operator. Format: tele2_lt, bite_lt, tele2_lv, etc.
string   $sendDate   (Optional) Message sending date. To be indicated only if the partner wants to send the message later. If not indicated, the message is sent immediately
string   $dlrUrl   (Optional) URL address, whereto the SMS delivery results should be sent
string   $priority   (Optional) Message priority. Higher priority is used if you need to send important messages (e.g. user registration approval) faster than other messages in queue (e.g. mass advertising)
string   $charset   (Optional) Sending text rule (charset). lisp – Lisped symbols, windows-1252 – Latin sybbols, windows-1257 – Baltic country symbols, windows-1251 – Cyrillic symbols, utf-8 – Any symbols
int   $serviceId   (Optional) MBS service ID, you will see seperated statictics of each service sending costs
int   $partnerId   (Optional) Partner ID

[ Top ]

method sendPacket [line 470]

array sendPacket( array $messages, [boolean $skipErrors = false], [string $sender = null], [string $message = null], [string $url = null], [string $ident = null], [string $type = 'SMS'], [string $operator = null], [string $sendDate = null], [string $dlrUrl = null], [string $priority = null], [string $charset = null], [int $serviceId = null], [int $partnerId = null], string $phone)

Dedicated for mass message sending.

All paramters are optional if they are described at each message in $messages array. If for example $sender is set - it will be aplied to all $messages items, that does not have 'sender' set.




Tags:

return:  

All messages or part of them successfully sent: array( 'status' => 'success', 'data' => array( // succesfully accepted messages provided with a unique identifier in the MBS – SMS_ID 'sent' => array( '66' => 123456, ), // rejected messages and their errors (then using parameter $skipErrors=true) 'errors' => array( '67' => array( 'field' => 'phone', // which field contains error 'field_error' => 'Wrong msisdn format', // error description ) ) ) )

Messages was not sent because of wrong data given: array( 'status' => 'fail', 'data' => array( 'sent' => array(), // rejected messages and their errors 'errors' => array( '67' => array( 'field' => 'phone', // which field contains error 'field_error' => 'Wrong msisdn format', // error description ) ) ) )

throws:  SMSCommTransportException
throws:  SMSCommException
access:  public
example:  example not found


Parameters:

array   $messages   Receiver's list - associative array, which contains key-value pairs. See examples below
boolean   $skipErrors   (Optional) If TRUE, send messages in any case, errors will be skipped
string   $sender   Sender phone number. This function is turned on by individual agreement, then all possible values should be listed
string   $phone   Receiver’s telephone number (MSISDN) in the international format "370xxxyyyyy"
string   $message   SMS text to be sent (in case of WapPush, the text is the link heading)
string   $url   (Optional) In case of WapPush, a link of WapPush to be sent
string   $ident   (Optional) External system unique identifier e.g. mass message identifier
string   $type   (Optional) Type of sending (SMS, WapPush), by default SMS
string   $operator   (Optional) To be indicated only if the partner knows the recipient’s operator. Format: tele2_lt, bite_lt, tele2_lv, etc.
string   $sendDate   (Optional) Message sending date. To be indicated only if the partner wants to send the message later. If not indicated, the message is sent immediately
string   $dlrUrl   (Optional) URL address, whereto the SMS delivery results should be sent
string   $priority   (Optional) Message priority. Higher priority is used if you need to send important messages (e.g. user registration approval) faster than other messages in queue (e.g. mass advertising)
string   $charset   (Optional) Sending text rule (charset). lisp – Lisped symbols, windows-1252 – Latin sybbols, windows-1257 – Baltic country symbols, windows-1251 – Cyrillic symbols, utf-8 – Any symbols
int   $serviceId   (Optional) MBS service ID, you will see seperated statictics of each service sending costs
int   $partnerId   (Optional) Partner ID

[ Top ]

method setDebug [line 852]

void setDebug( bools $state)

Turns debug on/off



Tags:

access:  public


Parameters:

bools   $state   Debug state. True - for on, false for off

[ Top ]

method setDebugType [line 878]

void setDebugType( string $type)

Sets debug type



Tags:

throws:  SMSCommException
access:  public
example:  example not found


Parameters:

string   $type   Debug type. Possible values: 'echo', 'buffer'

[ Top ]

method setPacketUrl [line 145]

void setPacketUrl( string $url)

Sets SMSComm API url for packet sending



Tags:

throws:  SMSCommException
access:  public


Parameters:

string   $url   SMSComm API url

[ Top ]

method setPassword [line 129]

void setPassword( string $password)

Sets SMSComm password



Tags:

throws:  SMSCommException
access:  public


Parameters:

string   $password   SMSComm password

[ Top ]

method setSmsUrl [line 161]

void setSmsUrl( string $url)

Sets SMSComm API url for single SMS sending



Tags:

throws:  SMSCommException
access:  public


Parameters:

string   $url   SMSComm API url

[ Top ]

method setUsername [line 113]

void setUsername( string $username)

Sets SMSComm username



Tags:

throws:  SMSCommException
access:  public


Parameters:

string   $username   SMSComm username

[ Top ]

method stop [line 608]

int stop( [string $ident = null], [int|array $messageId = null], [string $newIdent = null])

Dedicated to stop messages sending for unlimited time period (one or overal packet).

At least one search parameter is required.




Tags:

return:  Ammount of stopped messages
throws:  SMSCommTransportException
throws:  SMSCommException
access:  public


Parameters:

string   $ident   (Optional) Indicate which messages to stop, by external system unique identifier e.g. mass message identifier
int|array   $messageId   (Optional) Indicate which messages to stop, by unique MBS identifier or array of them
string   $newIdent   (Optional) If want to edit external system unique identifier while stoping e.g. stopped messages can be formed to a new packet

[ Top ]

method validate [line 206]

array validate( string $sender, string $phone, string $message, [string $url = null], [string $ident = null], [string $type = 'SMS'], [string $operator = null], [string $sendDate = null], [string $dlrUrl = null], [string $priority = null], [string $charset = null], [int $serviceId = null], [int $partnerId = null])

Validate single message - check message for possible errors



Tags:

return:  

On successful validation: array( 'status' => 'success', 'data' => null, )

On validation error: array( 'status' => 'fail', 'data' => array( 'field_error' => 'Wrong msisdn format', ) )

throws:  SMSCommTransportException
throws:  SMSCommException
access:  public


Parameters:

string   $sender   Sender phone number. This function is turned on by individual agreement, then all possible values should be listed
string   $phone   Receiver’s telephone number (MSISDN) in the international format "370xxxyyyyy"
string   $message   SMS text to be sent (in case of WapPush, the text is the link heading)
string   $url   (Optional) In case of WapPush, a link of WapPush to be sent
string   $ident   (Optional) External system unique identifier e.g. published advertisment unique number
string   $type   (Optional) Type of sending (SMS, WapPush), by default SMS
string   $operator   (Optional) To be indicated only if the partner knows the recipient’s operator. Format: tele2_lt, bite_lt, tele2_lv, etc.
string   $sendDate   (Optional) Message sending date. To be indicated only if the partner wants to send the message later. If not indicated, the message is sent immediately
string   $dlrUrl   (Optional) URL address, whereto the SMS delivery results should be sent
string   $priority   (Optional) Message priority. Higher priority is used if you need to send important messages (e.g. user registration approval) faster than other messages in queue (e.g. mass advertising)
string   $charset   (Optional) Sending text rule (charset). lisp – Lisped symbols, windows-1252 – Latin sybbols, windows-1257 – Baltic country symbols, windows-1251 – Cyrillic symbols, utf-8 – Any symbols
int   $serviceId   (Optional) MBS service ID, you will see seperated statictics of each service sending costs
int   $partnerId   (Optional) Partner ID

[ Top ]

method validatePacket [line 359]

array validatePacket( array $messages, [string $sender = null], [string $message = null], [string $url = null], [string $ident = null], [string $type = 'SMS'], [string $operator = null], [string $sendDate = null], [string $dlrUrl = null], [string $priority = null], [string $charset = null], [int $serviceId = null], [int $partnerId = null], string $phone)

Dedicated to check mass message for possible errors, sending not performed.

All paramters are optional if they are described at each message in $messages array. If for example $sender is set - it will be aplied to all $messages items, that does not have 'sender' set.




Tags:

return:  

All given messages are valid and contains no errors: array( 'status' => 'success', 'data' => array( 'errors' => array() ) )

Some of messages are not valid because of wrong data given: array( 'status' => 'fail', 'data' => array( // rejected messages and their errors 'errors' => array( '67' => array( 'field' => 'phone', // which field contains error 'field_error' => 'Wrong msisdn format', // error description ) ) ) )

throws:  SMSCommTransportException
throws:  SMSCommException
access:  public
example:  example not found


Parameters:

array   $messages   Receiver's list - associative array, which contains key-value pairs. See examples below
string   $sender   Sender phone number. This function is turned on by individual agreement, then all possible values should be listed
string   $phone   Receiver’s telephone number (MSISDN) in the international format "370xxxyyyyy"
string   $message   SMS text to be sent (in case of WapPush, the text is the link heading)
string   $url   (Optional) In case of WapPush, a link of WapPush to be sent
string   $ident   (Optional) External system unique identifier e.g. mass message identifier
string   $type   (Optional) Type of sending (SMS, WapPush), by default SMS
string   $operator   (Optional) To be indicated only if the partner knows the recipient’s operator. Format: tele2_lt, bite_lt, tele2_lv, etc.
string   $sendDate   (Optional) Message sending date. To be indicated only if the partner wants to send the message later. If not indicated, the message is sent immediately
string   $dlrUrl   (Optional) URL address, whereto the SMS delivery results should be sent
string   $priority   (Optional) Message priority. Higher priority is used if you need to send important messages (e.g. user registration approval) faster than other messages in queue (e.g. mass advertising)
string   $charset   (Optional) Sending text rule (charset). lisp – Lisped symbols, windows-1252 – Latin sybbols, windows-1257 – Baltic country symbols, windows-1251 – Cyrillic symbols, utf-8 – Any symbols
int   $serviceId   (Optional) MBS service ID, you will see seperated statictics of each service sending costs
int   $partnerId   (Optional) Partner ID

[ Top ]

method _callPacketAction [line 693]

array _callPacketAction( string $action, array $data)

Format data and call packet request



Tags:

return:  Request result array
throws:  SMSCommTransportException
throws:  SMSCommException
access:  protected


Parameters:

string   $action   SMSComm API action
array   $data   Data to be transfered to SMSComm API

[ Top ]

method _callSmsAction [line 664]

string _callSmsAction( string $action, array $data)

Format data and call sms request



Tags:

return:  Request result
throws:  SMSCommTransportException
throws:  SMSCommException
access:  protected


Parameters:

string   $action   SMSComm API action
array   $data   Data to be transfered to SMSComm API

[ Top ]

method _parseSmsResponse [line 825]

array _parseSmsResponse( string $response)

Parse SMSComm API old style format for single sms and convert to array



Tags:

throws:  SMSCommTransportException
access:  protected
example:  example not found


Parameters:

string   $response   SMSComm API SMS response

[ Top ]

method _sendRequest [line 743]

array _sendRequest( string $url, array $urlParams, [string|array $postParams = null])

Sends request to SMSComm API



Tags:

throws:  SMSCommTransportException
access:  protected


Parameters:

string   $url   SMSComm API url
array   $urlParams   GET parameters
string|array   $postParams   POST parameters

[ Top ]


Documentation generated on Thu, 08 Mar 2012 14:03:09 +0200 by phpDocumentor 1.4.4