Registration

Module Link

Creation and management of the short links. Using the functions of this module, you can shorten long URLs to use them in your SMS campaigns.

API methods

Creation of a new short link
https://api.mobizon.com.br/service/Link/Create

Short links deletion
https://api.mobizon.com.br/service/Link/Delete

Getting of the link
https://api.mobizon.com.br/service/Link/Get

Getting link's statistics
https://api.mobizon.com.br/service/Link/GetStats

Getting of the list of links
https://api.mobizon.com.br/service/Link/List

Short link's data editing
https://api.mobizon.com.br/service/Link/Update

Creation of a new short link

https://api.mobizon.com.br/service/Link/Create

Request parameters

data : array Link parameters (compulsory parameter)

ParameterTypeDescription
data[fullLink]stringFull link
data[status]integerLink status (0 - inactive, 1 - active)
data[expirationDate]dateLink expiration date (in the format YYYY-MM-DD), by default is not limited
data[comment]stringComment to the link

Sever response

array : Short link data

FieldTypeDescription
idintegerLink ID
codestringShort link code
shortLinkstringShort link

Errors codes

CodeDescription
1If any of the parameters contains invalid values.

Examples

curl -X POST \
  'https://api.mobizon.com.br/service/link/create?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/x-www-form-urlencoded' \
  -d 'data%5BfullLink%5D=http%3A%2F%2Fmobizon.kz&data%5Bstatus%5D=1&data%5BexpirationDate%5D=2020-10-05&data%5Bcomment%5D=Link+to+Christmass+PR+landing'
var data = "data%5BfullLink%5D=http%3A%2F%2Fmobizon.kz&data%5Bstatus%5D=1&data%5BexpirationDate%5D=2020-10-05&data%5Bcomment%5D=Link+to+Christmass+PR+landing";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});

xhr.open("POST", "https://api.mobizon.com.br/service/link/create?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK");
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("cache-control", "no-cache");

xhr.send(data);
<?php
use Mobizon\MobizonApi;

$api = new MobizonApi('KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK', 'api.mobizon.com.br');

// API method call
if ($api->call(
    'link',
    'create',
    array(
        'data' => array(
            //original long link
            'fullLink' => 'http://mobizon.kz',
            //link status
            'status' => '1',
            //link expiration date
            'expirationDate' => '2020-10-05',
            //link comment
            'comment' => 'Link to Christmass PR landing'
        )
    )
)
) {
    // Getting the result of an API request
    $result = $api->getData();
} else {
    // An error occurred during execution. Error code and message text output
    echo '[' . $api->getCode() . '] ' . $api->getMessage() . PHP_EOL;
}

Short links deletion

https://api.mobizon.com.br/service/Link/Delete

Request parameters

ParameterTypeDescription
idsarrayLinks' IDs

Sever response

Data array

FieldTypeDescription
processedarrayDeleted links' IDs
notProcessedarrayUndeleted links' IDs

Examples

curl -X POST \
  'https://api.mobizon.com.br/service/link/delete?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/x-www-form-urlencoded' \
  -d 'ids%5B0%5D=123&ids%5B1%5D=455&ids%5B2%5D=567'
var data = "ids%5B0%5D=123&ids%5B1%5D=455&ids%5B2%5D=567";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});

xhr.open("POST", "https://api.mobizon.com.br/service/link/delete?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK");
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("cache-control", "no-cache");

xhr.send(data);
<?php
use Mobizon\MobizonApi;

$api = new MobizonApi('KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK', 'api.mobizon.com.br');

// API method call
if ($api->call(
    'link',
    'delete',
    array(
        //short link IDs
        'ids' => array(
            '123',
            '455',
            '567'
        )
    )
)
) {
    // Getting the result of an API request
    $result = $api->getData();
} else {
    // An error occurred during execution. Error code and message text output
    echo '[' . $api->getCode() . '] ' . $api->getMessage() . PHP_EOL;
}

Getting of the link

https://api.mobizon.com.br/service/Link/Get

Request parameters

(to get it, it is necessary to pass one of the parameters)

ParameterTypeDescription
idintegerLink ID
codestringShort link code
shortLinkstringShort link

Server response

Data array

FieldTypeDescription
idintegerLink ID
userIdintegerUser ID
partnerIdintegerPartner ID
domainIdintegerLinks' domain ID
statusintegerLink status (0 - inactive, 1 - active)
moderatorStatusintegerLink's moderation status (0 - blocked, 1 - allowed)
clickCntintegerNumber of clicks on the link
createTsstringLink creation time
expirationDatestringLink expiry date (in format YYYY-MM-DD)
codestringShort link code
fullLinkstringOriginal link
shortLinkstringShort link
commentstringComment
moderatorCommentstringModerator's comment

Errors codes

CodeDescription
2If the link with the specified ID was not found
12If none of the parameters was passed

Examples

curl -X POST \
  'https://api.mobizon.com.br/service/link/get?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/x-www-form-urlencoded' \
  -d 'code=zxc'
var data = "code=zxc";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});

xhr.open("POST", "https://api.mobizon.com.br/service/link/get?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK");
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("cache-control", "no-cache");

xhr.send(data);
<?php
use Mobizon\MobizonApi;

$api = new MobizonApi('KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK', 'api.mobizon.com.br');

// API method call
if ($api->call(
    'link',
    'get',
    array(
        //link short code
        'code' => 'zxc'
    )
)
) {
    // Getting the result of an API request
    $result = $api->getData();
} else {
    // An error occurred during execution. Error code and message text output
    echo '[' . $api->getCode() . '] ' . $api->getMessage() . PHP_EOL;
}

Getting link's statistics

https://api.mobizon.com.br/service/Link/GetStats

Request parameters

ParameterTypeDescription
idsarrayLinks' IDs (maximum links number makes 5)
typestringStatistic's type, possible values:
monthly - number of clicks and redirects on monthly basis, the maximum interval for getting statistics - 3 years
daily - number of clicks and redirects on daily basis, the maximum interval for obtaining statistics - 90 days
hourly - number of clicks and redirects on an hourly basis, the maximum interval for getting statistics - 1 week
minute - number of clicks and redirects by the minute, the maximum interval for getting statistics - 3 hours.
criteriaarraySearch criteria (see Search criteria).

Search criteria

ParameterTypeDescription
criteria[dateFrom]stringRetrieve statistics since
(date and time in a format YYYY-MM-DD HH:ММ:SS)
criteria[dateTo]stringRetrieve statistics before
(date and time in a format YYYY-MM-DD HH:ММ:SS)

For time statistics monthly, daily, hourly, minute: if search criteria dateFrom and dateTo are not set, the statistics will be retrieved for the last maximum possible interval. if only the criterion dateFrom is set, or the period of time between dateFrom and dateTo exceeds maximum possible interval, the statistics will be retrieved for the last maximum possible interval, starting with the date dateFrom, if only one criterion dateTo is set, the statistics will be retrieved for the last maximum possible interval before the datedateTo

Server response

Data array

FieldTypeDescription
itemsarrayStatistical data
totalsstringCounters

Errors codes

CodeDescription
12If more than 5 link IDs are specified or the statistics' type is invalid

Examples

curl -X POST \
  'https://api.mobizon.com.br/service/link/getStats?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/x-www-form-urlencoded' \
  -d 'ids%5B0%5D=123&ids%5B1%5D=455&ids%5B2%5D=567&type=monthly&criteria%5BdateFrom%5D=2018-01-21+13%3A30%3A00'
var data = "ids%5B0%5D=123&ids%5B1%5D=455&ids%5B2%5D=567&type=monthly&criteria%5BdateFrom%5D=2018-01-21+13%3A30%3A00";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});

xhr.open("POST", "https://api.mobizon.com.br/service/link/getStats?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK");
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("cache-control", "no-cache");

xhr.send(data);
<?php
use Mobizon\MobizonApi;

$api = new MobizonApi('KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK', 'api.mobizon.com.br');

// API method call
if ($api->call(
    'link',
    'getStats',
    array(
        //short link IDs
        'ids' => array(
            '123',
            '455',
            '567'
        ),
        //statistics type
        'type' => 'monthly',
        //search criteria
        'criteria' => array(
            'dateFrom' => '2018-01-21 13:30:00'
        )
    )
)
) {
    // Getting the result of an API request
    $result = $api->getData();
} else {
    // An error occurred during execution. Error code and message text output
    echo '[' . $api->getCode() . '] ' . $api->getMessage() . PHP_EOL;
}

Getting of the list of links

https://api.mobizon.com.br/service/Link/List

Request parameters

ParameterTypeDescription
criteriaarraySearch criteria (see Search criteria)
paginationarrayPagination display options (see Pagination display options)
sortarraySorting options (see Sorting options)
Search criteria
ParameterTypeDescription
statusintegerLink status (0 - inactive, 1 - active)
moderatorStatusintegerLink's moderation status (0 - blocked, 1 - allowed)
createTsFromdatetimeLink creation date starting with (in format YYYY-MM-DD HH:MM:SS)
createTsTodatetimeLink creation date ending with (in format YYYY-MM-DD HH:MM:SS)
codestringSearch by a short link code
commentstringSearch by a comment
querystringFree search by link's attributes. Your request can consist of several words, separated by a space. The search will be carried out using the short link code, codes of the corresponding long tracking links and comment to the link. The required word combination should be included to any combination among the specified fields.
Pagination display options
ParameterTypeDescription
pageSizeintegerNumber of visible elements on the page
currentPageintegerCurrent page
Sorting options
ParameterDescription
idLink ID
statusLink status (0 - inactive, 1 - active)
moderatorStatusLink's moderation status (0 - blocked, 1 - allowed)
createTsLink creation time
expirationDateLink expiry date (in format YYYY-MM-DD)
codeShort link code
fullLinkOriginal link

Server response

Data array

FieldTypeDescription
itemsarrayList of found links (see List of links)
totalItemCountintegerTotal number of the elements found
List of links

Every link contains the following fields:

FieldTypeDescription
idintegerLink ID
statusintegerLink status (0 - inactive, 1 - active)
moderatorStatusintegerLink's moderation status (0 - blocked, 1 - allowed)
createTsstringLink creation time
expirationDatedateLink expiry date (in format YYYY-MM-DD)
codestringShort link code
fullLinkstringOriginal link
shortLinkstringShort link
domainIdintegerShort link domain ID
commentstringComment
moderatorCommentstringModerator's comment

Examples

curl -X POST \
  'https://api.mobizon.com.br/service/link/list?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/x-www-form-urlencoded' \
  -d 'criteria%5Bstatus%5D=1&criteria%5BmoderatorStatus%5D=1&pagination%5BcurrentPage%5D=2&pagination%5BpageSize%5D=50&sort%5BclickCnt%5D=ASC'
var data = "criteria%5Bstatus%5D=1&criteria%5BmoderatorStatus%5D=1&pagination%5BcurrentPage%5D=2&pagination%5BpageSize%5D=50&sort%5BclickCnt%5D=ASC";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});

xhr.open("POST", "https://api.mobizon.com.br/service/link/list?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK");
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("cache-control", "no-cache");

xhr.send(data);
<?php
use Mobizon\MobizonApi;

$api = new MobizonApi('KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK', 'api.mobizon.com.br');

// API method call
if ($api->call(
    'link',
    'list',
    array(
        //search criteria
        'criteria' => array(
            //only active links
            'status' => '1',
            //only approved by moderator
            'moderatorStatus' => '1'
        ),
        //pagination parameters
        'pagination' => array(
            //current page
            'currentPage' => '2',
            //number of displayed items per page
            'pageSize' => '50'
        ),
        //sorting parameters
        'sort' => array(
            //sorting by number of clicks ascending
            'clickCnt' => 'ASC'
        )
    )
)
) {
    // Getting the result of an API request
    $result = $api->getData();
} else {
    // An error occurred during execution. Error code and message text output
    echo '[' . $api->getCode() . '] ' . $api->getMessage() . PHP_EOL;
}

Short link's data editing

https://api.mobizon.com.br/service/Link/Update

Request parameters

ParameterTypeDescription
idintegerLink ID
dataintegerLink parameters (see Link parameters).

Link parameters

ParameterTypeDescription
data[status]integerLink status (0 - inactive, 1 - active)
data[expirationDate]dateLink expiry date (in format YYYY-MM-DD), by default is not limited
data[comment]stringComment on link

Server response

string : Short link

Errors codes

CodeDescription
1If any parameter contains invalid values.
2If the link with specified ID was not found.

Examples

curl -X POST \
  'https://api.mobizon.com.br/service/link/update?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/x-www-form-urlencoded' \
  -d 'id=123&data%5Bstatus%5D=0'
var data = "id=123&data%5Bstatus%5D=0";

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});

xhr.open("POST", "https://api.mobizon.com.br/service/link/update?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK");
xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("cache-control", "no-cache");

xhr.send(data);
<?php
use Mobizon\MobizonApi;

$api = new MobizonApi('KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK', 'api.mobizon.com.br');

// API method call
if ($api->call(
    'link',
    'update',
    array(
        //short link ID
        'id' => '123',
        'data' => array(
            //link status
            'status' => '0'
        )
    )
)
) {
    // Getting the result of an API request
    $result = $api->getData();
} else {
    // An error occurred during execution. Error code and message text output
    echo '[' . $api->getCode() . '] ' . $api->getMessage() . PHP_EOL;
}