Class SMS_Web_Sender

Description

SMS Web Sender

Instance of this class should be used to handle SMS requests.

Located in Program_Root/SMS_Web_Sender.php (line 36)


	
			
Variable Summary
object $current_site
object User_Agent $http_client
array $sms_sites
Method Summary
void SMS_Web_Sender ()
bool add_site (string $site_name, [string $user = null], [string $pass = null])
void add_sites (array $sites)
true add_site_object (object &$site)
string get_error ()
object User_Agent &get_http_client ()
array get_site_names ()
bool send (string $ccode, string $number, string $message)
void set_allow_smssend (bool $allow)
void set_http_client (object &$ua)
bool site_class_exists (string $site_name)
Variables
bool $allow_smssend (line 60)

Allow SMSSend scripts

object $current_site (line 54)

Current site

object User_Agent $http_client (line 42)

HTTP client (instance of User_Agent from HTTP Navigator)

array $sms_sites (line 48)

SMS Sites

Methods
Constructor SMS_Web_Sender (line 62)
void SMS_Web_Sender ()
add_site (line 294)

Add site

Example:


1 $sws->add_site('sitename', 'login_user', 'login_pass');
2 $sws->add_site('site2', 'user2', 'pass2');

  • return:

    returns true if $site_name was successfully added, false otherwise.

bool add_site (string $site_name, [string $user = null], [string $pass = null])
  • string $site_name
  • string $user
  • string $pass
add_sites (line 269)

Add sites

$sites should be an indexed array holding associative arrays, Example:


1 $sites = array();
2 $sites[] = array('name'=>'sitename', 'user'=>'login_user', 'pass'=>'login_pass');
3 $sites[] = array('name'=>'site2', 'user'=>'user2', 'pass'=>'pass2');
4 $sws->add_sites($sites);
This is equivalent to:

1 $sws->add_site('sitename', 'login_user', 'login_pass');
2 $sws->add_site('site2', 'user2', 'pass2');
The last method is preferred as add_site() returns true/false to indicate if site has been added successfully.

void add_sites (array $sites)
  • array $sites:

    indexed array holding associative arrays

add_site_object (line 338)

Add site object

This method should be used if the site you want to add is not available in one of the relevant site folders, or if the site object should be configured in a special way before being used.

Note:

  • $site must be a subclass of SMS_Site, otherwise it won't be added.
  • Make sure you call the follwing methods before adding $site to SMS_Web_Sender: set_site_name() to set the sitename, set_login() to set login details (if required by $site).

true add_site_object (object &$site)
  • object $site:

    must be a subclass of SMS_Site

get_allow_smssend (line 104)

Get allow SMSSend

bool get_allow_smssend ()
get_error (line 356)

Get error

This method should be called if send() fails. The last site to have attempted the send should hold a suitable error message which will be returned by this method.

string get_error ()
get_error_number (line 385)

Get error number

This method should be called if send() fails. The last site to have attempted the send should hold a suitable error number which will be returned by this method. To check the returned error number, you can use the SMS Web Sender error constants. Example:


1 $error = $sws->get_error_number();
2 if ($error == SWS_ERR_QUOTA) {
3 // not enough quota to send
4 }
Usually the error message produced by get_error() will be fine to display to users, but to determine the reason in code you can use this method and compare against the error constants.

Note: this method will always return one of the SWS_ERR_* constants, if the error number is unrecognised SWS_ERR_UNKNOWN will be returned. So only call this when you know there's been an error.

int get_error_number ()
get_http_client (line 122)

Get HTTP client

  • return:

    object

object User_Agent &get_http_client ()
get_site_names (line 134)

Get site names

Returns indexed array holding site names available for SMS_Web_Sender to use.

array get_site_names ()
send (line 193)

Send SMS

This method should be called only after some sites have been added to the SMS_Web_Sender object.

Example:


1 // create instance of SMS_Web_Sender
2 $sws =& new SMS_Web_Sender();
3 // add a site, in this example 'asite' must be a valid site our
4 // SMS_Web_Sender object can locate, see documentation for more on this.
5 $sws->add_site('asite', 'username', 'pass');
6 // Send message
7 if ($sws->send('+44', '07977777777', 'Hello, this is my message')) {
8 echo 'Success, your message has been sent';
9 } else {
10 echo 'Sorry, send failed, reason: ', $sws->get_error();
11 }

  • return:

    returns true on successful send, false on error

bool send (string $ccode, string $number, string $message)
  • string $ccode:

    country code

  • string $number:

    number to send (including leading '0' but excluding country code)

  • string $message:

    message

set_allow_smssend (line 94)

Set allow SMSSend

If enabled add_site() and get_site_names() will also look in the smssend_sites folder to find sites.

void set_allow_smssend (bool $allow)
  • bool $allow:

    pass true to enable, false to disable

set_http_client (line 113)

Set HTTP client

void set_http_client (object &$ua)
  • object $ua:

    User_Agent object

site_class_exists (line 241)

Site class exists

  • return:

    returns true if $site_name is a valid class, false otherwise.

bool site_class_exists (string $site_name)
  • string $site_name

Documention generated on Sat, 19 Jul 2003 03:43:29 +0100 by phpDocumentor 1.2.0