SMS API v1.3

1. SMS API Description

SMS API call method: HTTP GET.

HTTP encoding: UTF8.

URIs for the SMS API have the following structure:

{base_url}/{method_name}.php?{parameter1=value1}&{parameter2=value2}&...

Example:

GET http://localhost/smsapi/uLogin.php?uName=user1&pWord=pass1

If the function succeeds, the return value depends on the requested API method.

If the function fails, the return value is:

False[:Reason]

Reason is the optional. Common fail reasons:

Reason

Description

Connection

Unable to connect to MySQL database.

Session

Invalid session or the session has expired.

2. SMS API Methods

2.1. Login

Path:

uLogin.php?uName=<login>&pWord=<password>

Parameters:

Parameter

Required?

Description

uName

Yes

User login

pWord

Yes

User password

Return value: session token. Example:

CiuJvP9na0gURFPVhahvDlCfGyhfBCg58T2SvdxcpW

2.2. Get items

Path:

uGetItems.php?token=<session_token>

Parameters:

Parameter

Required?

Description

token

Yes

Session token

Return value: the list of the items (<item_id>&<description> pairs; one item per line). Example:

100&Yahoo
200&Microsoft

2.3. Log out

Path:

uExit.php?token=<session_token>

Parameters:

Parameter

Required?

Description

token

Yes

Session token

Return value: Ok

2.4. Get phone

Path:

GetPhone.php?token=<session_token>&ItemId=<item_id>&Phone=<phone_number>

Parameters:

Parameter

Required?

Description

token

Yes

Session token

ItemId

Yes

Item ID

Phone

No

Optional phone number

Return value: phone number. Example:

1234567890

2.5. Get message

Path:

GMessage.php?token=<session_token>&ItemId=<item_id>&Phone=<phone_number>

Parameters:

Parameter

Required?

Description

token

Yes

Session token

ItemId

Yes

Item ID

Phone

Yes

Phone number

Return values:

  • If new message received:

    MSG&<item_id>&<phone_number>&<message_text>
    
  • If no new new messages: Null

2.6. Release phone

Path:

ReleasePhone.php?token=<session_token>&phoneList=<phone_list>

Parameters:

Parameter

Required?

Description

token

Yes

Session token

phoneList

Yes

List of the <phone_number>-<item_id> pairs, delimited by semicolon (;). Example: 1234567890-100;123456791-100

Return value: Ok

2.7. Release all phones

Path:

ReleaseAllPhone.php?token=<session_token>

Parameters:

Parameter

Required?

Description

token

Yes

Session token

Return value: Ok

2.8. Add phone to the blacklist

Path:

AddBlack.php?token=<session_token>&phoneList=<phone_list>

Parameters:

Parameter

Required?

Description

token

Yes

Session token

phoneList

Yes

List of the <phone_number>-<item_id> pairs, delimited by semicolon (;). Example: 1234567890-100;123456791-100

Return value: Ok

3. SMS API Configuration

SMS API configuration file is smsconf.php.

Name

Description

$dbuser

MySQL login.

$dbpass

MySQL password.

$dbhost

MySQL host.

$dbschema

MySQL schema.

$max_user_sess

Max. number of concurrent user’s sessions. 0 - no limit.

$sess_expire_seconds

Session expires after these seconds. 0 - never expire.

$max_sess_phones

Max. number of phones per session. 0 - no limit.

$phone_expire_seconds

Phone number expires after these seconds. 0 - never expire.

$phone_hold_seconds

Hold phone numbers these seconds. 0 - don’t hold.

$log_level

1 - return log information in response. 0 - no logging.

$log_dberr

1 - return DB errors in response. 0 - no db logging.

4. Removing the .php extension with mod_rewrite

RewriteEngine on
RewriteBase /smsapi/
RewriteRule ^(uLogin|uGetItems|uExit|GetPhone|GMessage|ReleasePhone|ReleaseAllPhone)$ /smsapi/$1.php [L,QSA]