SMS API

Introduction

BSG API connects your website or application with mobile operators around the world.

XML documents are sent to the specified server address (the description of XML documents, their purpose and the server address are given below). The postmethod is used.
The headers of the data that needs to be sent should contain:
Content-type: text / xml; charset = utf-8
Encoding UTF-8 of XML documents.

Send your text message

Required parameters:

parameter description
login value your username
password value your password
type is always equal to “sms”
phone the phone number you want to send your text message to
client_id_sms SMS ID on the partner’s side. Optional Parameter. If there is a text message with such client_id_sms in the system, it will not be sent.
number_sms The serial number of the subscriber in an XML document. Required Parameter.

Example of sending:

Url: http://app.bsg.hk/xml
<? xml version = "1.0" encoding = "utf-8"?>
<request>
<message type = "sms">
<sender> sender </ sender>
<text> sms text </ text>
<abonent phone = "380631231233" client_id_sms = "3431" number_sms = "1" />
<abonent phone = "380633213211" client_id_sms = "3425" number_sms = "2" />
</ message>
<security>
<login value = "login" />
<password value = "password" />
</ security>
</ request>

In response, one of the following xml-documents may be issued:

In case of an error in the XML document that is being sent:

<? xml version = "1.0" encoding = "utf-8"?>
<response>
< error> error </ error>
</ response>

error – the error text message can take the following values:

  • the wrong format of an XML document
  • your account is locked
  • wrong login or password
  • post data not available

If the XML document contains no errors:

<? xml version = "1.0" encoding = "utf-8"?>
<response>
<information number_sms = "1" id_sms = "366" id_turn = "1428476741" parts = "1"> send </ information>
<information number_sms = "2" id_sms = "367" id_turn = "1428476741" parts = "1"> send </ information>
</ response>

parameter description
number_sms The serial number of the text message in the source XML document
id_sms Internal SMS ID that is used for delivery reports. If there was an error in the SMS transmission process, id_sms will be blank.
id_turn ID of the SMS delivery turn. This parameter is needed for compatibility.
parts The number of parts the text message is made of.
information SMS status («send»), if the text message has been sent.

Check the status of SMS text messages

Required parameters:

parameter description
login value Your username
password value Your password

Example:

Url: worldhttp://app.bsg.hk/xml/stat
<? xml version = "1.0" encoding = "utf-8"?>
<request>
<get_state>
<id_sms> 202 </ id_sms>
<id_sms> 203 </ id_sms>
<id_sms> 204 </ id_sms>
</ get_state>
<security>
<login value = "login" />
<password value = "password" />
</ security>
</ request>

 

In case of an error in the XML document that is being sent:


<? xml version = "1.0" encoding = "utf-8"?>
<response>
<error> error</error>
</response>

error – the error text can take the following values:

  • wrong xml format document
  • your account locked
  • wrong login or password
  • post data not available

If the document contains no errors:


<? xml version = "1.0" encoding = "utf-8"?>
<response>
<state raw_value = "0" id_sms = "202" time = "">partly_deliver</state>
<state raw_value = "0" id_sms = "203" time = "">partly_deliver</state>
</response>
/code>

parameter description
raw_value Message status according to SMPP 3.4 specification
id_sms Message id
time Status time. For some values may be empty.
state Message statuses:

  1. «send» - message status has not been received. In this case this parameter may be blank (time = "").
  2. «not_deliver» - the message was not delivered. The final status (does not change over time).
  3. «expired» - the subscriber was temporarily absent when the operator made attempts to deliver your message to them. The final status (does not change over time).
  4. «deliver» - the message was delivered. The final status (does not change over time).
  5. «partly_deliver» - the message was sent, but the status has not been received. The final status (does not change with time). Contact our technical support to find out more.

Check your balance.

Required parameters:

parameter description
login value your username
password value your password

Example:

Url: http://app.bsg.hk/xml/balance

xml-document:


<? xml version = "1.0" encoding = "utf-8"?>
<request>
<security>
<login value = "username" />
<password value = "password" />
</ security>
</ request>

 

In response one of the following XML documents may be issued:

In case of an error in the XML document that is being sent:


<? xml version = "1.0" encoding = "utf-8"?>
<response>
<error> error </ error>
< response>

error - the error text can take the following values:

  • wrong xml format document
  • wrong login or password
  • post data not available

In case the XML document contains no errors:

<? xml version = "1.0" encoding = "utf-8"?>
<response>
<money> 150 </ money>
</ response>

parameter description
money the balance of

Request information on a phone number

parameter description
login value Your username
password value Your password
phone Phone number

Example:

Url: http://app.bsg.hk/xml/def

xml-document:


<? xml version = "1.0" encoding = "utf-8"?>
<request>
<security>
<login value = "username" />
<password value = "password" />
</ security>
<phones>
<phone> 79612242243 </ phone>
<phone> 79612242244 </ phone>
</ phones>
</ request>

In response one of the following XML documents may be issued:

In case of an error in the XML document that is being sent:

<? xml version = "1.0" encoding = "utf-8"?>
<response>
<error> error </ error>
</ response>

error - the error text can take the following values:

  • wrong xml format document
  • wrong login or password
  • post data not available

In case the XML document contains no errors:


<? xml version = "1.0" encoding = "utf-8"?>
<response>
<phone operator = "beeline" country = "ru"> 79612242243 </ phone>
<phone operator = "beeline" country = "ru"> 79612242244 </ phone>
</ response>

parameter description
operator operator
country two-letter country code.
phone phone number

Introduction

BSG API connects your site or application with mobile operators around the world.

To use this API you need an account on BSG.hk and an API password, which can be created in your account.

Sending SMS

The following variables:

user Login
pwd API Password
sadr Sender
text TEXT
dadr Destination address

In response you’ll get an SMS ID (if sent to several phone numbers separated by comma, SMS ID in response will also be separated by commas. If the phone number was invalid – ID will be empty.)

http://app.bsg.hk/sendsms?user=login&pwd=password&sadr=sender&dadr=number&text=TEXT

Example on PHP:
$login = ‘xxxxx';
$password = ‘xxxxxx';
$srcaddr = urlencode(‘alphaname’);
$text = urlencode(‘TEXT’);
$num = ‘number';
$ch = curl_init();
$data = ‘http://app.bsg.hk/sendsms?
user=’.$login.’&pwd=’.
$password.’&sadr=’.$srcaddr.’&text=’.
$text.’&dadr=’.$num;
$urlData = urlencode( $data );
curl_setopt( $ch, CURLOPT_URL, $data );
curl_setopt( $ch,
CURLOPT_RETURNTRANSFER, true );
$out = curl_exec( $ch );
echo $out;
curl_close( $ch );

Checking status

The following variables:

user login
pwd API-password
smsid ID SMS

Possible states in response:

  • deliver;
  • not_deliver;
  • expired;

The status can also be blank, if the message is still in the queue or it has no status.

ERRORS

Possible errors during the query:

invalid_login_passw ord incorrect username or password
account_blocked account blocked
invalid_request invalid request

Menu