Difference between revisions of "Calculate Credits"

From Boxis.net API Docs
Jump to: navigation, search
(Example in XML (Success))
(Example URL with POST values)
 
(10 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
With this command, you are able to get how many credits you need to send a message.
 
With this command, you are able to get how many credits you need to send a message.
  
=== 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 'calculateCredits' value
 
|-
 
| - '''recipients_count''' (Integer)
 
''Number of message recipients''
 
|-
 
| - '''content''' (Integer)
 
''The message text''
 
|-
 
| - '''fast''' (Boolean)  - optional
 
''Setting this parameter 1 when message will be sent in fast mode
 
|-
 
|}
 
  
=== Output params ===
+
== 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 'calculateCredits' value
 +
 
 +
*'''recipients_count'''::Integer - ''Number of message recipients''
 +
 
 +
*'''content'''::String - ''The message text''
 +
 
 +
* '''encoding'''::String - ''Possible values ('''case sensitive!'''): UTF-8, ISO-8859-2, Windows-1252.
 +
 
 +
*'''fast'''::Boolean (optional) - ''Setting this parameter 1 if you want to know how many credits you need to when the message is sent in fast mode''
 +
 
 +
== Example URL with POST values ==
 +
 
 +
<pre>
 +
http://api.boxis.net/
 +
POST: version=1.0&returntype=xml&timestamp=1337853387&username=your@mail.com&authcode=1234567890&section=sms&action=calculateCredits&recipients_count=1&content=test1&encoding=UTF-8
 +
</pre>
 +
 
 +
== Output params ==
  
 
==== Example in XML (Success) ====
 
==== Example in XML (Success) ====
Line 62: Line 60:
 
</pre>
 
</pre>
  
==== Example in Json (Success) ====
+
==== Example in JSON (Success) ====
  
 
<pre>
 
<pre>
Line 68: Line 66:
 
  "resulttxt":"success",
 
  "resulttxt":"success",
 
  "params":{
 
  "params":{
   "sms_id":"133655724631563000002130"}
+
   "credit":4}
 
  "timestamp":1335777400}
 
  "timestamp":1335777400}
 
</pre>
 
</pre>
  
==== Example in Json (Error) ====
+
==== Example in JSON (Error) ====
  
 
<pre>
 
<pre>
Line 78: Line 76:
 
  "resulttxt":"Error: {error description}",
 
  "resulttxt":"Error: {error description}",
 
  "timestamp":1335777400}
 
  "timestamp":1335777400}
 +
</pre>
 +
 +
 +
 +
== Example using our PHP Class ==
 +
<pre>
 +
/* API LOGIN DETAILS */
 +
$email    = 'your@mail.com';    // your username
 +
$apikey  = '1234567890';        // your apikey
 +
 +
/* API COMMAND DETAILS */
 +
$apitype  = 'sms';
 +
$command  = 'calculateCredits';
 +
$params  = array(
 +
    'returntype' => 'xml',
 +
    'recipients_count' => 4,
 +
    '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);
 +
}
 +
/*
 +
 
</pre>
 
</pre>

Latest revision as of 14:58, 26 October 2012

SMS Function: calculateCredits

With this command, you are able to get how many credits you need to send a message.


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 'calculateCredits' value
  • recipients_count::Integer - Number of message recipients
  • content::String - The message text
  • encoding::String - Possible values (case sensitive!): UTF-8, ISO-8859-2, Windows-1252.
  • fast::Boolean (optional) - Setting this parameter 1 if you want to know how many credits you need to when the message is sent in fast mode

Example URL with POST values

http://api.boxis.net/
POST: version=1.0&returntype=xml&timestamp=1337853387&username=your@mail.com&authcode=1234567890&section=sms&action=calculateCredits&recipients_count=1&content=test1&encoding=UTF-8

Output params

Example in XML (Success)

<?xml version="1.0" encoding="UTF-8"?>
<return>
  <result>1</result>
  <resulttxt>success</resulttxt>
  <params>
    <credit>4</credit>
  </params>
  <timestamp>1336558351</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)

{"result":"1",
 "resulttxt":"success",
 "params":{
   "credit":4}
 "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  = 'calculateCredits';
$params   = array(
    'returntype' => 'xml',
    'recipients_count' => 4,
    '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);
}
/*