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.
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
https://api.mobizon.com.br/service/Link/Create
data : array Link parameters (compulsory parameter)
Parameter | Type | Description |
---|---|---|
data[fullLink] | string | Full link |
data[status] | integer | Link status (0 - inactive, 1 - active) |
data[expirationDate] | date | Link expiration date (in the format YYYY-MM-DD ), by default is not limited |
data[comment] | string | Comment to the link |
array : Short link data
Field | Type | Description |
---|---|---|
id | integer | Link ID |
code | string | Short link code |
shortLink | string | Short link |
Code | Description |
---|---|
1 | If any of the parameters contains invalid values. |
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;
}
https://api.mobizon.com.br/service/Link/Delete
Parameter | Type | Description |
---|---|---|
ids | array | Links' IDs |
Data array
Field | Type | Description |
---|---|---|
processed | array | Deleted links' IDs |
notProcessed | array | Undeleted links' IDs |
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;
}
https://api.mobizon.com.br/service/Link/Get
(to get it, it is necessary to pass one of the parameters)
Parameter | Type | Description |
---|---|---|
id | integer | Link ID |
code | string | Short link code |
shortLink | string | Short link |
Data array
Field | Type | Description |
---|---|---|
id | integer | Link ID |
userId | integer | User ID |
partnerId | integer | Partner ID |
domainId | integer | Links' domain ID |
status | integer | Link status (0 - inactive, 1 - active) |
moderatorStatus | integer | Link's moderation status (0 - blocked, 1 - allowed) |
clickCnt | integer | Number of clicks on the link |
createTs | string | Link creation time |
expirationDate | string | Link expiry date (in format YYYY-MM-DD ) |
code | string | Short link code |
fullLink | string | Original link |
shortLink | string | Short link |
comment | string | Comment |
moderatorComment | string | Moderator's comment |
Code | Description |
---|---|
2 | If the link with the specified ID was not found |
12 | If none of the parameters was passed |
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;
}
https://api.mobizon.com.br/service/Link/GetStats
Parameter | Type | Description |
---|---|---|
ids | array | Links' IDs (maximum links number makes 5) |
type | string | Statistic'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. |
criteria | array | Search criteria (see Search criteria). |
Parameter | Type | Description |
---|---|---|
criteria[dateFrom] | string | Retrieve statistics since (date and time in a format YYYY-MM-DD HH:ММ:SS ) |
criteria[dateTo] | string | Retrieve 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
Data array
Field | Type | Description |
---|---|---|
items | array | Statistical data |
totals | string | Counters |
Code | Description |
---|---|
12 | If more than 5 link IDs are specified or the statistics' type is invalid |
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;
}
https://api.mobizon.com.br/service/Link/List
Parameter | Type | Description |
---|---|---|
criteria | array | Search criteria (see Search criteria) |
pagination | array | Pagination display options (see Pagination display options) |
sort | array | Sorting options (see Sorting options) |
Parameter | Type | Description |
---|---|---|
status | integer | Link status (0 - inactive, 1 - active) |
moderatorStatus | integer | Link's moderation status (0 - blocked, 1 - allowed) |
createTsFrom | datetime | Link creation date starting with (in format YYYY-MM-DD HH:MM:SS ) |
createTsTo | datetime | Link creation date ending with (in format YYYY-MM-DD HH:MM:SS ) |
code | string | Search by a short link code |
comment | string | Search by a comment |
query | string | Free 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. |
Parameter | Type | Description |
---|---|---|
pageSize | integer | Number of visible elements on the page |
currentPage | integer | Current page |
Parameter | Description |
---|---|
id | Link ID |
status | Link status (0 - inactive, 1 - active) |
moderatorStatus | Link's moderation status (0 - blocked, 1 - allowed) |
createTs | Link creation time |
expirationDate | Link expiry date (in format YYYY-MM-DD ) |
code | Short link code |
fullLink | Original link |
Data array
Field | Type | Description |
---|---|---|
items | array | List of found links (see List of links) |
totalItemCount | integer | Total number of the elements found |
Every link contains the following fields:
Field | Type | Description |
---|---|---|
id | integer | Link ID |
status | integer | Link status (0 - inactive, 1 - active) |
moderatorStatus | integer | Link's moderation status (0 - blocked, 1 - allowed) |
createTs | string | Link creation time |
expirationDate | date | Link expiry date (in format YYYY-MM-DD ) |
code | string | Short link code |
fullLink | string | Original link |
shortLink | string | Short link |
domainId | integer | Short link domain ID |
comment | string | Comment |
moderatorComment | string | Moderator's comment |
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;
}
https://api.mobizon.com.br/service/Link/Update
Parameter | Type | Description |
---|---|---|
id | integer | Link ID |
data | integer | Link parameters (see Link parameters). |
Parameter | Type | Description |
---|---|---|
data[status] | integer | Link status (0 - inactive, 1 - active) |
data[expirationDate] | date | Link expiry date (in format YYYY-MM-DD ), by default is not limited |
data[comment] | string | Comment on link |
string : Short link
Code | Description |
---|---|
1 | If any parameter contains invalid values. |
2 | If the link with specified ID was not found. |
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;
}