Difference between revisions of "Send SMS"

From Boxis.net API Docs
Jump to: navigation, search
(Example URL with POST values)
 
(75 intermediate revisions by the same user not shown)
Line 1: Line 1:
=SMS Function: Send SMS=
+
 
 +
=SMS Function: sendSMS=
  
 
With this command, you are able to send SMS with boxis.net.
 
With this command, you are able to send SMS with boxis.net.
  
=== Input params ===
 
{|
 
|-
 
| - '''sender_name'''::String
 
|-
 
| - '''recipients'''::Array of Strings
 
|-
 
| - '''content'''::String
 
|-
 
| - '''flash'''::Boolean::0/1 (optional)
 
|-
 
| - '''fast'''::Boolean::0/1 (optional)
 
|-
 
| - '''schedule'''::Boolean::0/1 (optional)
 
|-
 
| - '''timesend'''::String Format 'YYYY-MM-DD HH:MM' (optional, when schedule is 1)
 
|-
 
|}
 
  
=== Output params ===
+
== Input params ==
  
==== Example in XML ====
+
*'''version'''::String - ''API version (e.g. '1.0')''
  
===== Success =====
+
*'''timestamp'''::String - ''Sequence of characters, denoting the date and time (e.g '1336553826')''
====== Simple single SMS =====
+
 
 +
*'''username'''::String - ''User e-mail address (e.g 'mail1@example.com')''
 +
 
 +
*'''authcode'''::String - '' md5 hash consisting of the concatenation of timestamp and user_key (e.g md5(1336553826BX3KwWU2SuqvoEWnjYmOibf'))''
 +
 
 +
*'''section'''::String - ''API module name. Use 'sms' value
 +
 
 +
* '''action'''::String - ''API module function. Use 'sendSMS' value
 +
 
 +
*'''recipients[1],recipients[2],..recipients[n]'''::Array of Strings - ''List of phobne numbers''
 +
 
 +
* '''content'''::String - ''The message text. Content of one message is normally 160 characters per single SMS or 70 in case of using at least one special character (polish characters are considered to be special characters). The maximal message is set to 459 normal characters or 201 if special chars are used and it is being sent as one block of 3 messages joined together and charged as three messages.''
 +
 
 +
* '''encoding'''::String - ''Possible values ('''case sensitive!'''): UTF-8, ISO-8859-2, Windows-1252
 +
 
 +
*'''flash'''::Boolean (optional) - ''Sending a message in flash mode can be activated by setting this parameter to 1''
 +
 
 +
* '''fast'''::Boolean (optional) - ''Setting this parameter to „1” will result in sending message with the highest priority which ensures the quickest possible time of delivery. This parameter may be used for both PRO and ECO messages. Fast messages costs 50% more than normal message. '''Attention!''' Mass and marketing messages  mustn’t be sent with fast parameter''
 +
 
 +
*'''schedule'''::Boolean (optional) - ''Adding a message to the schedule can be activated by setting this parameter to 1''
 +
 
 +
* '''timesend'''::String (optional, use when schedule is 1) - ''Date in 'yyyy-mm-dd hh:mm' format when message will be sent. Setting a past date will result in sending message instantly''
 +
 
 +
== Example URL with POST values ==
 +
 
 +
<pre>
 +
https://api.boxis.net/
 +
POST: returntype=xml&sender_name=boxis.net&recipients[1]=48599131568&content=test1&encoding=UTF-8&version=1.0&username=your@mail.com&timestamp=1337844592&authcode=1234567890&section=sms&action=sendSMS
 +
</pre>
 +
 
 +
== Output params ==
 +
 
 +
==== Example in XML (Success) ====
 +
 
 +
* Send Single SMS (no scheduled)
 
<pre>
 
<pre>
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
Line 40: Line 57:
 
</pre>
 
</pre>
  
===== error =====
+
* Send Single Scheduled SMS
 +
<pre>
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
<return>
 +
  <result>1</result>
 +
  <resulttxt>success</resulttxt>
 +
  <params>
 +
    <sms_id>133655645431563000007320</sms_id>
 +
  </params>
 +
  <timestamp>1335767184</timestamp>
 +
</return>
 +
</pre>
 +
 
 +
* Send Bulk SMS (no scheduled)
 +
<pre>
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
<return>
 +
  <result>1</result>
 +
  <resulttxt>success</resulttxt>
 +
  <params>
 +
    <sent>
 +
      <sms1>
 +
        <id>133654685431563000002080</id>
 +
        <phone>48511141565</phone>
 +
      </sms1>
 +
      <sms2>
 +
        <id>133654685409553000016930</id>
 +
        <phone>48514645553</phone>
 +
      </sms2>
 +
    </sent>
 +
    <not_sent>
 +
      <phone>48714645553</phone>
 +
    </not_sent>
 +
  </params>
 +
  <timestamp>1335767184</timestamp>
 +
</return>
 +
</pre>
 +
 
 +
* Send Bulk Scheduled SMS
 +
<pre>
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
<return>
 +
  <result>1</result>
 +
  <resulttxt>success</resulttxt>
 +
  <params>
 +
    <scheduled>
 +
      <sms1>
 +
        <id>133654685431563000002080</id>
 +
        <phone>48511141565</phone>
 +
      </sms1>
 +
      <sms2>
 +
        <id>133654685409553000016930</id>
 +
        <phone>48514645553</phone>
 +
      </sms2>
 +
    </scheduled>
 +
    <not_scheduled>
 +
      <phone>48714645553</phone>
 +
    </not_scheduled>
 +
  </params>
 +
  <timestamp>1335767184</timestamp>
 +
</return>
 +
</pre>
 +
 
 +
==== Example in XML (Error) ====
  
 
<pre>
 
<pre>
Line 46: Line 126:
 
<return>
 
<return>
 
   <result>0</result>
 
   <result>0</result>
   <resulttxt>Error: {error description}</resulttxt>
+
   <resulttxt>error: {error description}</resulttxt>
  <params/>
+
 
   <timestamp>1335767184</timestamp>
 
   <timestamp>1335767184</timestamp>
 
</return>
 
</return>
 
</pre>
 
</pre>
==== Example in Json  ====
 
  
===== success =====
+
==== Example in JSON (Success) ====
  
 +
* Send Single SMS (no scheduled)
 
<pre>
 
<pre>
 
{"result":"1",
 
{"result":"1",
 
  "resulttxt":"success",
 
  "resulttxt":"success",
  "params":[],
+
  "params":{
 +
  "sms_id":"133655724631563000002130"}
 
  "timestamp":1335777400}
 
  "timestamp":1335777400}
 
</pre>
 
</pre>
  
===== error =====
+
* Single Scheduled SMS
 +
<pre>
 +
{"result":"1",
 +
"resulttxt":"success",
 +
"params":{
 +
  "sms_id":"133655724631563000002130"}
 +
"timestamp":1335777400}
 +
</pre>
 +
 
 +
* Send Bulk SMS (no scheduled)
 +
<pre>
 +
{"result":"1",
 +
"resulttxt":"success",
 +
"params":{
 +
  "sent":{
 +
    "sms1":{
 +
      "id":"133655714331563000008070",
 +
      "phone":"48511131564"}},
 +
    "not_sent":{
 +
      "sms1":"48717131563",
 +
      "sms2":"48611171563"}},
 +
"timestamp":1335777400}
 +
</pre>
 +
 
 +
* Send Bulk Scheduled SMS
 +
<pre>
 +
{"result":"1",
 +
"resulttxt":"success",
 +
"params":{
 +
  "scheduled":{
 +
    "sms1":{
 +
      "id":"133655714331563000008070",
 +
      "phone":"48511131564"}},
 +
    "not_scheduled":{
 +
      "sms1":"48717131563",
 +
      "sms2":"48611171563"}},
 +
"timestamp":1335777400}
 +
</pre>
 +
 
 +
==== Example in JSON (Error) ====
  
 
<pre>
 
<pre>
 
{"result":"0",
 
{"result":"0",
 
  "resulttxt":"Error: {error description}",
 
  "resulttxt":"Error: {error description}",
"params":[],
 
 
  "timestamp":1335777400}
 
  "timestamp":1335777400}
 
</pre>
 
</pre>
  
==== Errors Descriptions ====
+
 
{|
+
== Example using our PHP Class ==
|-
+
<pre>
| - 'domain' is not valid
+
/* API LOGIN DETAILS */
|-
+
$email    = 'your@mail.com';    // your username
| - there is no such tld
+
$apikey  = '1234567890';        // your apikey
|-
+
 
| - 'years' value is not valid
+
/* API COMMAND DETAILS */
|-
+
$apitype  = 'sms';
| - 'ns' could not be greater than five
+
$command  = 'sendSMS';
|-
+
$params  = array(
| - 'protect-privacy' value is not valid
+
    'returntype' => 'xml',
|-
+
    'sender_name' => 'boxis.net',
| - domain 'testdomain.com' is not available
+
    'recipients[1]' => '48599131568',
|-
+
    'content' => 'test1',
| - domain not created
+
);
|}
+
 
 +
/* PROCESS THE ACTION */
 +
$boxisAPI = new BoxisAPIConnection($email, $apikey);
 +
$return = $boxisAPI->call($apitype, $command, $params, $timestamp);
 +
 
 +
/* TIMESTAMP SYNCHRONIZATION (JSON EXAMPLE)
 +
if($return['timestamperror']) {
 +
    $timestamp = $return['timestamp'];
 +
    $return = $boxisAPI->call($apitype, $command, $params, 'json', $timestamp);
 +
}
 +
*/
 +
 
 +
/* TIMESTAMP SYNCHRONIZATION (XML EXAMPLE)*/
 +
/*
 +
if($return->timestamperror) {
 +
    $timestamp = $return->timestamp;
 +
    $return = $boxisAPI->call($apitype, $command, $params, 'xml', $timestamp);
 +
}
 +
/*
 +
 
 +
</pre>

Latest revision as of 09:09, 27 June 2014

SMS Function: sendSMS

With this command, you are able to send SMS with boxis.net.


Input params

  • version::String - API version (e.g. '1.0')
  • timestamp::String - Sequence of characters, denoting the date and time (e.g '1336553826')
  • username::String - User e-mail address (e.g 'mail1@example.com')
  • authcode::String - md5 hash consisting of the concatenation of timestamp and user_key (e.g md5(1336553826BX3KwWU2SuqvoEWnjYmOibf'))
  • section::String - API module name. Use 'sms' value
  • action::String - API module function. Use 'sendSMS' value
  • recipients[1],recipients[2],..recipients[n]::Array of Strings - List of phobne numbers
  • content::String - The message text. Content of one message is normally 160 characters per single SMS or 70 in case of using at least one special character (polish characters are considered to be special characters). The maximal message is set to 459 normal characters or 201 if special chars are used and it is being sent as one block of 3 messages joined together and charged as three messages.
  • encoding::String - Possible values (case sensitive!): UTF-8, ISO-8859-2, Windows-1252
  • flash::Boolean (optional) - Sending a message in flash mode can be activated by setting this parameter to 1
  • fast::Boolean (optional) - Setting this parameter to „1” will result in sending message with the highest priority which ensures the quickest possible time of delivery. This parameter may be used for both PRO and ECO messages. Fast messages costs 50% more than normal message. Attention! Mass and marketing messages mustn’t be sent with fast parameter
  • schedule::Boolean (optional) - Adding a message to the schedule can be activated by setting this parameter to 1
  • timesend::String (optional, use when schedule is 1) - Date in 'yyyy-mm-dd hh:mm' format when message will be sent. Setting a past date will result in sending message instantly

Example URL with POST values

https://api.boxis.net/
POST: returntype=xml&sender_name=boxis.net&recipients[1]=48599131568&content=test1&encoding=UTF-8&version=1.0&username=your@mail.com&timestamp=1337844592&authcode=1234567890&section=sms&action=sendSMS

Output params

Example in XML (Success)

  • Send Single SMS (no scheduled)
<?xml version="1.0" encoding="UTF-8"?>
<return>
  <result>1</result>
  <resulttxt>success</resulttxt>
  <params>
    <sms_id>133655645431563000007320</sms_id>
  </params>
  <timestamp>1335767184</timestamp>
</return>
  • Send Single Scheduled SMS
<?xml version="1.0" encoding="UTF-8"?>
<return>
  <result>1</result>
  <resulttxt>success</resulttxt>
  <params>
    <sms_id>133655645431563000007320</sms_id>
  </params>
  <timestamp>1335767184</timestamp>
</return>
  • Send Bulk SMS (no scheduled)
<?xml version="1.0" encoding="UTF-8"?>
<return>
  <result>1</result>
  <resulttxt>success</resulttxt>
  <params>
    <sent>
      <sms1>
        <id>133654685431563000002080</id>
        <phone>48511141565</phone>
      </sms1>
      <sms2>
        <id>133654685409553000016930</id>
        <phone>48514645553</phone>
      </sms2>
    </sent>
    <not_sent>
       <phone>48714645553</phone>
    </not_sent>
  </params>
  <timestamp>1335767184</timestamp>
</return>
  • Send Bulk Scheduled SMS
<?xml version="1.0" encoding="UTF-8"?>
<return>
  <result>1</result>
  <resulttxt>success</resulttxt>
  <params>
    <scheduled>
      <sms1>
        <id>133654685431563000002080</id>
        <phone>48511141565</phone>
      </sms1>
      <sms2>
        <id>133654685409553000016930</id>
        <phone>48514645553</phone>
      </sms2>
    </scheduled>
    <not_scheduled>
       <phone>48714645553</phone>
    </not_scheduled>
  </params>
  <timestamp>1335767184</timestamp>
</return>

Example in XML (Error)

<?xml version="1.0" encoding="UTF-8"?>
<return>
  <result>0</result>
  <resulttxt>error: {error description}</resulttxt>
  <timestamp>1335767184</timestamp>
</return>

Example in JSON (Success)

  • Send Single SMS (no scheduled)
{"result":"1",
 "resulttxt":"success",
 "params":{
   "sms_id":"133655724631563000002130"}
 "timestamp":1335777400}
  • Single Scheduled SMS
{"result":"1",
 "resulttxt":"success",
 "params":{
   "sms_id":"133655724631563000002130"}
 "timestamp":1335777400}
  • Send Bulk SMS (no scheduled)
{"result":"1",
 "resulttxt":"success",
 "params":{
   "sent":{
     "sms1":{
       "id":"133655714331563000008070",
       "phone":"48511131564"}},
    "not_sent":{
      "sms1":"48717131563",
      "sms2":"48611171563"}},
 "timestamp":1335777400}
  • Send Bulk Scheduled SMS
{"result":"1",
 "resulttxt":"success",
 "params":{
   "scheduled":{
     "sms1":{
       "id":"133655714331563000008070",
       "phone":"48511131564"}},
    "not_scheduled":{
      "sms1":"48717131563",
      "sms2":"48611171563"}},
 "timestamp":1335777400}

Example in JSON (Error)

{"result":"0",
 "resulttxt":"Error: {error description}",
 "timestamp":1335777400}


Example using our PHP Class

/* API LOGIN DETAILS */
$email    = 'your@mail.com';    // your username
$apikey   = '1234567890';        // your apikey

/* API COMMAND DETAILS */
$apitype  = 'sms';
$command  = 'sendSMS';
$params   = array(
    'returntype' => 'xml',
    'sender_name' => 'boxis.net',
    'recipients[1]' => '48599131568',
    'content' => 'test1',
);

/* PROCESS THE ACTION */
$boxisAPI = new BoxisAPIConnection($email, $apikey);
$return = $boxisAPI->call($apitype, $command, $params, $timestamp);

/* TIMESTAMP SYNCHRONIZATION (JSON EXAMPLE)
if($return['timestamperror']) {
    $timestamp = $return['timestamp'];
    $return = $boxisAPI->call($apitype, $command, $params, 'json', $timestamp);
}
*/

/* TIMESTAMP SYNCHRONIZATION (XML EXAMPLE)*/
/*
if($return->timestamperror) {
    $timestamp = $return->timestamp;
    $return = $boxisAPI->call($apitype, $command, $params, 'xml', $timestamp);
}
/*