SMS REST – API

REST

The REST API is a easy way to read and write to smsNet.

Authorization

The API uses basic authorization, and all requests must be authorized at every request.
A 32 bit token is used to authenticat the request.

Encoding

UTF8

Address

https://login.smsnet.se/v1/

Format

The REST API is only using JSON all requests body should be in JSON and all responses will be JSON. Make sure you set Request.Header.Content-Type to “application/json”.

Error

Here is a list of the error codes that can get return
404 – The request can not be found
500 – Internal error
300 – Reciver is missing or invalid
301 – Sender is missing or invalid
302 – Content is missing or invalid
303 – Schedual date and time are invalid or has passed

Overview

  • Send SMS
  • Status SMS

Send SMS

POST/sms
Request

Parameter Type Mandatory Description
authorizationId string yes The 32 bit authorization token used to authenticat the request
destination int yes The phone number to the receiver of the SMS
originator string yes Who sent the SMS, where was it from. Either a number or a string max 11 characters
text string yes The actual SMS text message
type string no Type can be set to either text for regular text message or flash to be displayed directly on the cellphones display
schedule datetime no When you like the SMS to be delivered, should be in the format 2015-01-01 10:30:00

Sample request

POST/sms HTTP/1.1
Content-Type: application/json; charset=UTF-8
{
    "authorizationId": "dXNlcm5hbWU6cGFzc3dvcmQ",
    "destination": "0709846366",
    "originator": "smsNet",
    "text": "Hello world",
    "type": "text",
    "schedule": "2015-01-01 10:30:00"
}

Response

Parameter Type Mandatory Description
trackingid string yes The trackind id is used to track the delivery of the SMS, this should be stored at the senders side to receive delivery reports
authorizationId string yes The 32 bit authorization token used to authenticat the request
destination int yes The phone number to the receiver of the SMS
originator string yes Who sent the SMS, where was it from. Either a number or a string max 11 characters
text string yes The actual SMS text message
type string no Type can be set to either text for regular text message or flash to be displayed directly on the cellphones display
schedule datetime no When you like the SMS to be delivered, should be in the format 20150101T10:30:00
status string yes The status, that can be acknowledge,delivered,buffered or failed
POST/sms HTTP/1.1
Content-Type: application/json; charset=UTF-8
{
    "trackingid": "4ebeab48-ee03-474f-bc79-c6db082c2bad",
    "authorizationId": "dXNlcm5hbWU6cGFzc3dvcmQ",
    "destination": "0709846366",
    "originator": "smsNet",
    "text": "Hello world",
    "type": "text",
    "schedule": "2015-01-01 10:30:00",
    "status": "acknowledge"
}

Code in PHP:

<?php

function apiCall ($requestMethod, $entity, $body = null) { 

	$curl = curl_init('https://login.smsnet.se/v1/' . $entity);
	$options = array(
  		'Content-Type: application/json',
  		'Accept: application/json'
	);
	
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
	curl_setopt($curl, CURLOPT_HTTPHEADER, $options);
	curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $requestMethod);
	
	if ($requestMethod == 'POST' || $requestMethod == 'PUT') {
		curl_setopt($curl, CURLOPT_POSTFIELDS, $body);
	}

	$curlResponse = curl_exec($curl);
	curl_close($curl);
	return $curlResponse;
}

$obj['authorizationId'] = "secret";
$obj['destination'] 	= "0709-846366";
$obj['originator'] 	= utf8_encode("smsNet");
$obj['text'] 		= utf8_encode("Hello world!");
$obj['type'] 		= "text";
$obj['schedule'] 	= "";

$responce = apiCall('POST', 'sms', json_encode($obj));

$returnObj = json_decode($responce);