API REFERENCE

3.1 Operation: Create an account in web2SMS


3.1.1 Request


URI: POST /prepaid/message

POST /prepaid/message HTTP/1.1

Host: www.web2sms.ro

Connection: close

Accept-encoding: gzip, deflate

User-Agent: Zend_Http_Client

Authorization: Basic YWVjNjY3NWQ3ZjY2ODQ4ZjdiMDkzZjY0NmZmYjcyZD

Content-Type: application/json

Content-Length: 732

{

"apiKey":"XXXX675d7f66848f7bXXX646ffb72d007d9XXXX",

"sender":"1868",

"recipient":"07ZZYYYXXX",

"message":"SMS message to be send to recipient",

"scheduleDatetime":"1445436328",

"validityDatetime":"1446303928",

"callbackUrl":"",

"userData":"123456789",

"visibleMessage":"Message to be visible anywhere in the platform except reports",

"nonce":"1445430328"

}

Signature create:

signature = sha512(apiKey.nonce.Method.URI.sender.recipient.message.visibleMessage.scheduleDate.validityDate.callbackUrl.secret)

Where . (point) means concatenate.

Parameters:

apiKey (string/mandatory) – provided by the web2SMS staff

sender - (string / optional)

recipient - (string / mandatory) mobile phone number

message - (string / mandatory)

scheduleDatetime - (timestamp / optional) – format timestamp

validityDatetime - (timestamp / optional) – format timestamp

callbackUrl - (string / optional)

visibleMessage - (string / optional) (this value will be shown in the web2sms platform. Max length 160 chars)

userData - (string / optional)

nonce - (timestamp / mandatory) – time of the request


3.1.2 Response

Returns a JSON object containing the details about the sms created. If the operation performed successfully, then it will always return 201 HTTP status code.

Example:

HTTP/1.1 201 Created

Date: Sat, 14 Dec 2013 01:01:20 GMT

Server: Apache/2.2.22 (Ubuntu)

X-powered-by: PHP/5.3.10-1ubuntu3.9

Cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

Pragma: no-cache

Vary: Accept-Encoding

Content-length: 108

Connection: close

Content-type: application/json

{

"id":"XXXX7ea6ebda71YYYY7ac97ca1b2ZZZZ|X|YY",

"error":

{

"code":0,

"message":"IDS_Prepaid_MessageController_E_OK"

}

}

The Location HTTP header provides the URI of the created resource ( XXXX7ea6ebda71YYYY7ac97ca1b2ZZZZ|X|YY is the HashID to uniquely identify this message).

This HashID is useful in getting the message status or delete it (conditions apply).

Response parameters:

id - (string / mandatory) unique identifier of the newly created sms.


3.2.1 Request

URI: GET /prepaid/message

GET /prepaid/message HTTP/1.1

Host: www.web2sms.ro

Connection: close

Accept-encoding: gzip, deflate

User-Agent: Zend_Http_Client

Authorization: Basic YWVjNjY3NWQ3ZjY2ODQ4ZjdiMDkzZjY0NmZ

Content-Type: application/json

Content-Length: 119

{"apiKey":"XXXX675d7f66848f7bXXX646ffb72d007d9XXXX","id":"XXXX7ea6ebda71YYYY7ac97ca1b2ZZZZ|X|YY","nonce":"1445433976"}

Signature create:

signature = sha512(apiKey.nonce.Method.URI.id.secret)

Where . (point) means concatenate.

Parameters:

apiKey (string/mandatory) – provided by the web2SMS staff

nonce - (timestamp / mandatory) – time of the request

id - (string / mandatory) HashID returned in POST request if successful


3.2.2 Response

Returns a JSON object containing the details about the sms identified by HashId. If the operation performed successfully, then it will always return 201 HTTP status code.

Example:

HTTP/1.1 201 Created

Date: Sat, 14 Dec 2013 01:01:20 GMT

Server: Apache/2.2.22 (Ubuntu)

X-powered-by: PHP/5.3.10-1ubuntu3.9

Cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

Pragma: no-cache

Vary: Accept-Encoding

Content-length: 76

Connection: close

Content-type: application/json

{

"status":"2",

"error":

{

"code":0,

"message":"IDS_Prepaid_MessageController_E_OK"

}

}

Status represents the status message as explaind here: https://sites.google.com/a/netopia-system.com/wiki-web2sms/documentatia-tehnica-api-web2sms/metoda-4---checkstatus

Response parameters:

status - (string / mandatory) Status of message


3.3.1 Request

A message can be deleted only if current status of message is 0 and the schedule datetime is less than current server datetime minus 5 minutes.

URI: DELETE /prepaid/message

DELETE /prepaid/message HTTP/1.1

Host: www.web2sms.ro

Connection: close

Accept-encoding: gzip, deflate

User-Agent: Zend_Http_Client

Authorization: Basic NmY4YzU1NDMzNzE4ODBjYmE0NDk1YjVjYTY1OTFmZjM

Content-Type: application/json

Content-Length: 119

{

"apiKey":"XXXX675d7f66848f7bXXX646ffb72d007d9XXXX",

"id":"XXXX7ea6ebda71YYYY7ac97ca1b2ZZZZ|X|YY",

"nonce":"1445439045"

}

Signature create:

signature = sha512(apiKey.nonce.Method.URI.id.secret)

Where . (point) means concatenate.

Parameters:

apiKey (string/mandatory) – provided by the web2SMS staff

nonce - (timestamp / mandatory) – time of the request

id - (string / mandatory) HashID returned in POST request if successful


3.3.2 Response

Returns a JSON object containing the details about the sms identified by HashId. If the operation performed successfully, then it will always return 201 HTTP status code.

Example:

HTTP/1.1 201 Created

Date: Sat, 14 Dec 2013 01:01:20 GMT

Server: Apache/2.2.22 (Ubuntu)

X-powered-by: PHP/5.3.10-1ubuntu3.9

Cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

Pragma: no-cache

Vary: Accept-Encoding

Content-length: 76

Connection: close

Content-type: application/json

{

"result":"DELETED",

"error":

{

"code":0,

"message":"IDS_Prepaid_MessageController_E_OK"

}

}


3.4.1 Request

A message can be deleted only if current status of message is 0 and the schedule datetime is less than current server datetime minus 5 minutes.

URI: BALANCE /prepaid/message

BALANCE /prepaid/message HTTP/1.1

Host: www.web2sms.ro

Connection: close

Accept-encoding: gzip, deflate

User-Agent: Zend_Http_Client

Authorization: Basic NmY4YzU1NDMzNzE4ODBjYmE0NDk1YjVjYTY1OTFmZjM

Content-Type: application/json

Content-Length: 119

{

"apiKey":"XXXX675d7f66848f7bXXX646ffb72d007d9XXXX",

"nonce":"1445439045"

}

Signature create:

signature = sha512(apiKey.nonce.Method.URI.secret)

Where . (point) means concatenate.

Parameters:

apiKey (string/mandatory) – provided by the web2SMS staff

nonce - (timestamp / mandatory) – time of the request


3.4.2 Response

Returns a JSON object containing the details about the sms identified by HashId. If the operation performed successfully, then it will always return 201 HTTP status code.

Example:

HTTP/1.1 201 Created

Date: Sat, 14 Dec 2013 01:01:20 GMT

Server: Apache/2.2.22 (Ubuntu)

X-powered-by: PHP/5.3.10-1ubuntu3.9

Cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

Pragma: no-cache

Vary: Accept-Encoding

Content-length: 76

Connection: close

Content-type: application/json

{

"result":"BALANCE",

"error":

{

"code":0,

"message":"<VALUE OF BALANCE>"

}

}

      Implementation example in PHP for get Balance Rest Request

<?php 

------

try

{

    //BALANCE

        $httpClient = new Zend_Http_Client();

        $httpClient->setUri("http://www.web2sms.ro/prepaid/message");

        $httpClient->setMethod(Zend_Http_Client::GET);

        $httpClient->setHeaders("Content-Type", "application/json");

    

        $crtDate = new Zend_Date();

        $apiKey = "";  //value provided

        $httpClient->setHeaders("BALANCE", $apiKey);

        $nonce = $crtDate->get(Zend_Date::TIMESTAMP); 

        $method = "GET";

        $url = "/prepaid/message";

        $data = $crtDate->get(Zend_Date::TIMESTAMP);

        $secret = "";  //value provided

        $string = $apiKey . $nonce . $method . $url . $secret;

        $signature = hash('sha512', $string);

        $httpClient->setAuth($apiKey, $signature);

        $data = array(

            "apiKey" => $apiKey,

            "nonce" => $nonce);

    $httpClient->setRawData(Zend_Json::encode($data));

    $httpResponse = $httpClient->request();

   $httpResponse = $httpClient->request();

var_dump($httpResponse);

var_dump($httpResponse->getBody());

var_dump(json_decode($httpResponse->getBody()));

}

catch (Zend_Http_Client_Exception $e)

{

var_dump($e->getMessage());

return array();

}

catch (Zend_Uri_Exception $e)

{

var_dump($e->getMessage());

return array();

}

      Implementation example in PHP for POST Rest Request 

<?php

…....

try

{

//POST

$httpClient = new Zend_Http_Client();

$httpClient->setUri("http://www.web2sms.ro/prepaid/message");

$httpClient->setMethod(Zend_Http_Client::POST);

$httpClient->setHeaders("Content-Type", "application/json");

//parametrii metoda

$crtDate = new Zend_Date();

$apiKey = ""; //value provided

$nonce = $crtDate->get(Zend_Date::TIMESTAMP);

$method = "POST";

$url = "/prepaid/message";

$sender = "";

$recipient = "07xxxxxxxx";//To be fill in !

$message = "";

$visibleMessage = "How the message do you want to appear on the interface. If empty string than $message value will be shown";

$scheduleDate = ''; //Format yyyy-MM-dd HH:mm:ss

$validityDate = ''; //Format yyyy-MM-dd HH:mm:ss

$callbackUrl = '';

$secret = ""; // value provided

$string = $apiKey . $nonce . $method . $url . $sender . $recipient . $message . $visibleMessage . $scheduleDate . $validityDate . $callbackUrl . $secret;

$signature = hash('sha512', $string);

$httpClient->setAuth($apiKey, $signature);

$data = array(

"apiKey" => $apiKey,

"sender" => $sender,

"recipient" => $recipient,

 message" => $message,

"scheduleDatetime" => $scheduleDate,

"validityDatetime" => $validityDate,

"callbackUrl" => $callbackUrl,

"userData" => "",

"visibleMessage" => $visibleMessage,

"nonce" => $nonce);

$httpClient->setRawData(Zend_Json::encode($data));

$httpResponse = $httpClient->request();

var_dump($httpResponse);

var_dump($httpResponse->getBody());

var_dump(json_decode($httpResponse->getBody()));

}

catch (Zend_Http_Client_Exception $e)

{

var_dump($e->getMessage());

return array();

}

catch (Zend_Uri_Exception $e)

{

var_dump($e->getMessage());

return array();

}