Creating and managing short links. With the functions of this module, you can shorten long URLs for use in your SMS campaigns.
Creating a Short Link
https://api.mobizon.com.br/service/Link/Create
Deleting Short Links
https://api.mobizon.com.br/service/Link/Delete
Retrieving Basic Data of a Short Link
https://api.mobizon.com.br/service/Link/Get
Getting Campaign Short Links
https://api.mobizon.com.br/service/Link/GetLinks
Retrieving Click Statistics for Links
https://api.mobizon.com.br/service/Link/GetStats
Getting List of Links
https://api.mobizon.com.br/service/Link/List
Editing Short Link Data
https://api.mobizon.com.br/service/Link/Update
https://api.mobizon.com.br/service/Link/Create
This method is designed for creating short links.
data array
– Link parameters
Parameter | Type | Description |
---|---|---|
data[fullLink] | string | Full link. The link that needs to be shortened in the correct URL format. For example: https://help.mobizon.com/api-docs/sms-api?utm_campaign=docs&utm_source=help&utm_medium=test#server-response-format or www.mobizon.com |
data[status] | integer | Status of the short link: 0 – link inactive; 1 – link active (default). |
data[expirationDate] | date | Expiration date of the link. The link will be valid until the end of the specified day in the user's time zone. By default, the link does not expire. Format: YYYY-MM-DD . |
data[comment] | string | Comment on the link. This field helps to easily find the short link among others. For example: "Black Friday Discounts" or "Negative Balance Reminder". Maximum comment length is 255 characters. |
array
: Data of the created short link
Field | Type | Description |
---|---|---|
id | integer | Link identifier. |
code | string | Short link code. |
shortLink | string | Short link. |
Code | Description |
---|---|
0 | Short link successfully created. |
1 | If any parameters contain 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.com&data%5Bstatus%5D=1&data%5BexpirationDate%5D=2020-10-05&data%5Bcomment%5D=Comment+on+the+link'
var data = "data%5BfullLink%5D=http%3A%2F%2Fmobizon.com&data%5Bstatus%5D=1&data%5BexpirationDate%5D=2020-10-05&data%5Bcomment%5D=Comment+on+the+link";
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(
//full link
'fullLink' => 'http://mobizon.com',
//link status
'status' => '1',
//link expiration date
'expirationDate' => '2020-10-05',
//comment on the link
'comment' => 'Comment on the link'
)
)
)
) {
// 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
This method is intended for deleting short links.
Parameter | Type | Description |
---|---|---|
ids | array | Link identifiers. |
Array of data
Field | Type | Description |
---|---|---|
processed | array | Identifiers of deleted links. |
notProcessed | array | Identifiers of links that were not deleted. |
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(
//link identifiers
'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
This method allows you to retrieve the basic data of a short link by one of its three parameters: id, code, shortLink.
Only one short link's data can be retrieved in a single request.
To retrieve the data, one of the parameters must be passed:
Parameter | Type | Description |
---|---|---|
id | integer | Link identifier. |
code | string | Short link code. A combination of characters unique to each short link. Located at the very end of the short link. Example: http://mbz.im/mgjf, where mgjf is the short link code. |
shortLink | string | Short link. URL created by our service, which redirects your visitors to the link you initially specified. Example: http://mbz.im/mgjf. |
Array of data
Field | Type | Description |
---|---|---|
id | integer | Link identifier. |
status | integer | Status set by the user: 0 – link inactive; 1 – link active. |
moderatorStatus | integer | Status set by the administrator: 0 – blocked by the administrator; 1 – approved by the administrator. |
clickCnt | integer | Number of clicks on the short link. |
createTs | string | Creation time of the short link. Format: YYYY-MM-DD HH:MM:SS . |
expirationDate | string | Expiration date of the short link. Format: YYYY-MM-DD .If the date is not set, the field value is NULL. |
code | string | Short link code. |
fullLink | string | Full link. |
shortLink | string | Short link. |
comment | string | User's comment on the short link. If the comment is absent, the field value is NULL. |
moderatorComment | string | Moderator's comment. If the comment is absent, the field value is NULL. |
Code | Description |
---|---|
0 | Basic data of the short link successfully retrieved. |
2 | If the link with the specified identifier is not found. |
12 | If none of the parameters are 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(
//short link 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/GetLinks
This method allows you to get information and statistics of the campaign's short links.
Parameter | Type | Description |
---|---|---|
campaignId | integer | Campaign identifier. |
Link object structure: an array of short links, where each element contains the following fields:
Field | Type | Description |
---|---|---|
id | integer | Short link identifier. |
code | string | Short link code. |
fullLink | string | Full link. |
shortLink | string | Short link. |
clickCnt | integer | Number of clicks on the short link. |
redirectCnt | integer | Number of redirects via the short link. |
comment | string | User comment on the short link. |
Code | Description |
---|---|
0 | Campaign short links successfully retrieved. |
2 | If the campaign is not found. |
https://api.mobizon.com.br/service/Link/GetStats
This method is designed to retrieve click statistics for one or more short links by their ID.
Data can be grouped by months, days, hours, minutes.
Parameter | Type | Description |
---|---|---|
ids | array | Link identifiers. Maximum number of IDs in a request – 5. Parameter syntax: ids[] for each identifier. |
type | string | Type of requested statistics. Allows you to get data in various time intervals: monthly – number of clicks per month. Maximum interval for retrieving statistics – 3 years; daily – number of clicks per day. Maximum interval for retrieving statistics – 90 days; hourly – number of clicks per hour. Maximum interval for retrieving statistics – 1 week; minute – number of clicks per minute. Maximum interval for retrieving statistics – 3 hours. |
criteria | array | Search criteria (See table Search Criteria). |
Statistical data retrieval is based on the specified date and time.
Parameter | Type | Description |
---|---|---|
criteria[dateFrom] | string | Retrieve statistics starting from the specified date and time. Format: YYYY-MM-DD HH:MM:SS . |
criteria[dateTo] | string | Retrieve statistics up to the specified date and time. Format: YYYY-MM-DD HH:MM:SS . |
Important: if the search criteria dateFrom
and dateTo
are not set, the type
field statistics will be retrieved for the last maximum possible interval.
If only one criterion dateFrom
is set or the time interval between dateFrom
and dateTo
exceeds the maximum allowed interval, statistics will be retrieved for the maximum allowed interval starting from the dateFrom
date.
If only the dateTo
criterion is set, statistics will be retrieved for the maximum possible period up to the dateTo
date.
Array of data:
Field | Type | Description |
---|---|---|
items | array | Statistical data. |
totals | string | Total number of clicks for the requested period. |
Code | Description |
---|---|
0 | Statistics successfully retrieved. |
12 | If more than 5 link identifiers are specified or the type of statistics is incorrectly specified. |
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(
//link identifiers
'ids' => array(
'123',
'455',
'567'
),
//type of statistics
'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
This method allows you to get a list of created short links. The search can be performed by ID and short link fields.
Parameter | Type | Description |
---|---|---|
criteria | array | Search criteria (see the table Search Criteria). |
pagination | array | Pagination parameters (see the table Pagination Parameters). |
sort | array | Sorting parameters (see the table Sorting Parameters). |
Information about the fields of the short link by which the search is performed. The search can be done by one field or a combination of fields.
Parameter | Type | Description |
---|---|---|
criteria[status] | integer | Search by short link status: 0 – link is inactive; 1 – link is active. |
criteria[moderatorStatus] | integer | Search by link moderation status: 0 – blocked; 1 – approved. |
criteria[createTsFrom] | datetime | Search by link creation date, starting from the specified date. Format: YYYY-MM-DD . |
criteria[createTsTo] | datetime | Search by link creation date and time up to the specified date and time. Format: YYYY-MM-DD HH:MM:SS . |
criteria[query] | string | Search by various link attributes. The search can be performed by: Short link code; Recipient tracking code; Short link comment. |
These parameters are intended for structured (partial) output of the requested information.
Parameter | Type | Description |
---|---|---|
pagination[pageSize] | integer | Number of items displayed per page (25, 50, 100). |
pagination[currentPage] | integer | Current page Page numbering starts from 0. |
These parameters allow you to sort the search results by one of the fields in ascending (ASC) or descending (DESC) order.
For example:
Sort by short link code in ascending order – sort[code]=ASC
.
Sort by original link in descending order – sort[fullLink]=DESC
.
Parameter | Description |
---|---|
sort[createTs] | Sort by link creation date and time. Format: YYYY-MM-DD HH:MM:SS . |
sort[expirationDate] | Sort by link expiration date. Format: YYYY-MM-DD . |
sort[clickCnt] | Sort by number of clicks. |
sort[code] | Sort by short link code. |
sort[fullLink] | Sort by original link. |
Array of data:
Field | Type | Description |
---|---|---|
items | array | List of found links. For a description of the short link fields, see the description of the Link/Get method. |
totalItemCount | integer | Total number of found items. |
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',
//links approved by the moderator
'moderatorStatus' => '1'
),
//pagination parameters
'pagination' => array(
//current page
'currentPage' => '2',
//number of items displayed per page
'pageSize' => '50'
),
//sorting parameters
'sort' => array(
//sort by number of clicks in ascending order
'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
This method allows you to change the parameters of a created short link.
Parameter | Type | Description |
---|---|---|
id | integer | Link identifier. |
data | integer | Editable link parameters specified in the table Link Parameters. |
Parameter | Type | Description |
---|---|---|
data[status] | integer | Status of the short link: 0 – link inactive; 1 – link active. |
data[expirationDate] | date | Expiration date of the short link. Format: YYYY-MM-DD .If the value is not provided, the link will be valid indefinitely. |
data[comment] | string | Comment on the link. Maximum comment length is 255 characters. |
string
– Short link.
Code | Description |
---|---|
0 | Parameters successfully changed. |
1 | If any parameters contain invalid values. |
2 | If the link with the specified identifier is 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(
//link identifier
'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;
}