This module contains functions for creating SMS campaigns, adding recipients to them using one of the possible ways, launching a campaign, deleting of irrelevant campaigns, reviewing the list of campaigns and searching on them.
Adding recipients to a bulk SMS campaign
https://api.mobizon.gmbh/service/Campaign/AddRecipients
Creating of a new campaign
https://api.mobizon.gmbh/service/Campaign/Create
Full deletion of the campaign
https://api.mobizon.gmbh/service/Campaign/Delete
Getting of the main campaign data
https://api.mobizon.gmbh/service/Campaign/Get
Getting of the campaign's statistical data
https://api.mobizon.gmbh/service/Campaign/GetInfo
Receipt of campaign's short links
https://api.mobizon.gmbh/service/Campaign/GetLinks
Receipt of the campaigns list
https://api.mobizon.gmbh/service/Campaign/List
Launching of the campaign
https://api.mobizon.gmbh/service/Campaign/Send
https://api.mobizon.gmbh/service/Campaign/AddRecipients
Within one request it is only allowed to send one of the following recipients’ data source:
If you try to send several different types of recipients at once, the error 12 will be returned.
If you need to add recipients from multiple sources to the same campaign, please proceed with several requests. When adding recipient numbers, contacts or contact cards, the maximum number of recipients in one request shouldn’t exceed 500 entries. If the limit is exceeded, an error 12 will be returned and none of the recipients will be added.
To add any desired number of contacts to the same campaign, divide the list into parts consisting of 500 or fewer elements and send each new part by a separate API request - the recipients will be added to the existing list unless the replace=1 parameter is specified.
Uploading of numbers, contacts and contact cards is performed within the main webserver thread and returns the result for each processed recipient as an array (check the returned data format below).
Import from a contact group or file creates a background task (asynchronous loading) and returns its ID for further status tracking. In this case the API response code will be 100.
Mobile numbers you are sending must be entered in international format. All extraneous characters will be removed automatically.
Each number will be verified through sending of a message to it using the country code and operator prefix.
All non-verified numbers will be rejected with the corresponding error code (code), and for each added number the generated message ID (messageId) will be returned to enable further status request.
If not all imported recipients were added successfully (some errors occurred), then the API returns one of the following response codes: - 98 - if not all recipients were added, but at least one recipient was verified - 99 - if no recipient was verified.
While the recipients are being added, the campaign is blocked for any other adding recipients' request, therefore simultaneous import is impossible.
Parameter | Type | Description |
---|---|---|
id | integer | ID of the campaign, you want to add recipients to |
recipients | array string | Regular campain recipients can be sent as a:
recipient key and the recipient's number as a value, it can also include (but not necessarily) elements with keys corresponding to the names of variables (placeholders) in the SMS text (without surrounding curly braces). At the same time, if any of the placeholders contained in text was not passed, then processing will go on depending on the passed parameter placeholdersFlag (see the flag description below). Examples of requests are listed below. |
recipientContacts | array string | Array or string (separated by commas or new lines) of contacts from the contact book. The contact can be specified as:
|
recipientGroups | array string | The array or the string of (comma- or line-separated) contact group IDs, from which the contacts should be added to the campaign. Only unique numbers will be added. |
recipientsFile | file | The object of the file with the recipients is the CSV or Excel (only XLS) file with recipients' numbers in the international format. For regular campaign the numbers are distributed one per line. For template campaign numbers are distributed one by one in a row in any of the columns with the recipient header, other columns may contain placeholders. Column headers must correspond to the placeholders in the text of SMS (without surrounding curly braces). To name a placeholder use only Latin letters and numbers or characters '_ ' and '- '. If there are columns with the same headings, an error will be returned. At the same time, if there are no corresponding columns for any of the placeholders contained in the text, then processing will occur depending on the placeholdersFlag value passed to the params parameter (see the flag description below). |
params | array | Advanced settings (see Advanced settings table). |
Parameter | Type | Description |
---|---|---|
params[replace] | integer | Indicates whether it is necessary to delete all already added recipients and to start adding again: 0 - no, add recipients to previously added ones (default value); 1 - yes, delete all before adding new ones; |
params[placeholdersFlag] | integer | Processing of the missing variables (placeholders) for the template campaign. If no variable values for the placeholder are found, then one of the following scenario is possible: 1 - the message is added to the campaign, but the placeholders remain in the text as they are (default scenario); 2 — the message is added, but placeholders are deleted (if you just need to send, not to reject the message); 3 — the message is rejected with an error indicating missing data for the placeholder in text. |
params[recipientsFileEncoding] | string | Encoding in the recipient data file, available are the following encodings: KOI8-R, CP866, WINDOWS-1252, WINDOWS-1251, UTF-8, ASCII, ISO-8859-1, UCS-2, default is: UTF-8. |
params[recipientsFileSkipHeader] | integer | Indicates whether it is necessary to skip the first line of the file and start processing from the second. Can be of use if recipients are uploaded from a file in which the first line contains the columns' names. In this case, it is better to skip the first line and start processing the file from the second one. Possible values are: 0 - start from the first line (default value); 1 - skip the first line of the file and start processing from the second (used by default within the template campaign); < br> For the template campaign the value of this parameter is always set to 1 and can't be redefined, since the first line must contain the names of the placeholder variables. |
params[recipientsFileDelimiter] | string | Column separator in the recipients; data file, by default: , (comma) |
params[recipientsFileEnclosure] | string | Text separator in the recipients data file, default: ' (single quotes) |
array | integer : When recipients are uploaded from a list of numbers, contacts or contact cards, an array is returned, each element of which contains data of the added recipients:
Field | Type | Description |
---|---|---|
recipient | string | Number of the recipient being added to the campaign |
code | integer | Recipient adding result code: 0 - the number was successfully added to the campaign 1 - there is no phone number in the transferred data or the value is empty 2 - no phone number found in the transferred data (most likely the data was incorrectly formatted) 3 - the number doesn't correspond to the international format requirements 4 - the number was already added to the campaign (deletion of duplicates from a campaign) 5 - the number is included to the stop-list (it can be either your stop-list or the system stop-list) 6 - sending to the country of destination is limited by your account settings 7 - it is impossible to identify the operator and/or the country of destination 8 - the system is not able to send to this operator, please contact our technical support to clarify the possibility to send it 20 - sent data does not contain all necessary placeholders (if placeholdersFlag is set to 1 value)30 - contact card was not found in the contact book ( recipient equals to null )31 - contact card does not contain a mobile number ( recipient equals tonull )32 - contact was not found in the contact book ( recipient equals tonull )51 - for technical reasons it is currently impossible to create a short link 99 - system error adding recipient number |
messageId | integer | The identifier of the added message; if the number was added, by the specified identifier you can check the status of the message. |
number | integer | Initial value of the recipient's number, added by the user (if the recipient's number was transmitted) |
contactId | integer | The identifier of the added contact (when recipientsContactIds was sent) |
contactCardId | integer | The identifier of the added contact card(when recipientsCardIds was sent) |
When you upload a recipients' file or a list of contact groups, the numeric identifier of the background recipients' adding task is returned. Details for tasks servicing are to be checked here.
Code | Description |
---|---|
1 | If any parameter contains invalid values. |
2 | If the campaign with specified ID is not found. |
10 | If the specified campaign is blocked by another recipients' adding process or campaign status doesn't allow adding of recipients. |
12 | If none of the recipients type is sent or multiple types of recipients are sent in a single request. |
98 | If at least one of all sent recipients is not added to the campaign. |
99 | If in the query processing result none of the recipients is added to the campaign. |
100 | If the background recipients' adding task was started. Details for tasks servicing are to be checked here. |
To add the list of recipients to the campaign, send the array, containing them, like this:
recipients[]=380971112233&recipients[]=79101112233&recipients[]=77071112233
or like that:
recipients=380971112233,79101112233,77071112233
Both entry formats are identical.
Let's suppose, that SMS contains the following text: Hello, {name}! Your balance as at {date} equals to {balance}{currency}.
In this case parameter recipients
should send these types of data:
recipients[0][recipient]=380971112233
&recipients[0][name]=%D0%92%D0%B0%D1%81%D0%B8%D0%BB%D0%B8%D0%B9
&recipients[0][date]=26.10.17
&recipients[0][balance]=123.45
&recipients[0][currency]=%D0%B3%D1%80%D0%BD
&recipients[1][recipient]=380971112255
&recipients[1][name]=%D0%9E%D0%BB%D1%8C%D0%B3%D0%B0
&recipients[1][date]=26.10.17
&recipients[1][balance]=3222.99
&recipients[1][currency]=%D1%80%D1%83%D0%B1
&recipients[2][recipient]=4901122211112
&recipients[2][name]=Markus
&recipients[2][date]=26.10.17
&recipients[2][balance]=555.45
&recipients[2][currency]=eur
All data in the HTTP request fields sent to the server should be prior encoded in the URL encoded string (each programming language has a corresponding function for this).
https://api.mobizon.gmbh/service/Campaign/Create
This method allows you to create a new SMS-campaign. After creating a campaign, add the recipients to it and then send it.
data array
– Campaign parameters
Parameter | Type | Description |
---|---|---|
data[name] | string | The name of the campaign. Using this field, it is more convenient to navigate through the campaigns being created. For example: «Black Friday» discounts» or «Negative account balance reminder». The maximum length of the campaign name is 255 characters. |
data[text] | string | Text of SMS message to be sent. For a template campaign (data[type]=3), this text must contain variables that will be replaced by values unique to each recipient. The variable should be written by symbols of a Latin letters, numbers and symbols "_" , "-" , and is framed in curly braces, for example: {name} or {clientBalance} .In the text of the message you can use short links and the function of tracking recipients to find out which of the recipients followed your link. |
data[type] | integer | Type of campaign:1 – Single message (sending to one number);2 – Mass campaign (set by default);3 – Template campaign (the text of the message can contain placeholders, which will be replaced with unique text for each recipient). |
data[from] | string | Sender's signature. To use the sender's own signature, it must be registered in advance. If no signature is specified, the default signature or standard service signature will be used. |
data[rateLimit] | integer | Limitation of the number of messages sent during the period of time specified in the field ratePeriod .This option allows you to slow down the speed of sending a large SMS-campaign in order to distribute the load on your Call Center. Send speed limit – no more than 100 messages per second in recalculation for per second sending. Messages are sent at equal intervals, in packets of 10 pieces, based on the specified rateLimit for ratePeriod . For example, if you specify the speed of 600 and the period of 60, then every second will be sent 600/60 = 10 SMS. |
data[ratePeriod] | integer | Time period in seconds for which the quantity of SMS specified in the rateLimit field will be sent.Maybe equal: 60 – 1 minute;3600 – 1 hour;86400 – 1 day. |
data[deferredToTs] | string | Date and time of the deferred sending of the campaign. It is possible to set the beginning of sending not earlier than one hour, and not later than 14 days. Format: YYYY-MM-DD HH:MM:SS . |
data[mclass] | integer | The class of the message that is being sent:0 – messages are displayed in a pop-up window and are not saved anywhere (flashSMS);1 – messages are saved in the phone's Inbox (set by default). |
data[validity] | integer | Maximum waiting time for the message to be delivered if the recipient cannot accept it immediately. For example, if your phone is turned off or out of range. It is specified in minutes from the moment of sending: from 60 (1 hour) to 1440 (24 hours). |
data[trackShortLinkRecipients] | integer | Function of tracking recipients. Available only if the text of the message (in the field data[text] ) contains short links created in our service.0 – do not use the function (set by default);1 – to use the function. |
integer : campaign ID, if the campaign was successfully created
Code | Description |
---|---|
0 | The campaign is successfully created. |
1 | If any of the parameters contains invalid values. |
curl -X POST \
'https://api.mobizon.gmbh/service/campaign/create?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK' \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'data%5Btype%5D=3&data%5Bfrom%5D=Alpha&data%5Btext%5D=Hello+%7Bname%7D%21+Your+balance+by+%7Bdate%7D+is+%7Bbalance%7D%7Bcurrency%7D.'
var data = "data%5Btype%5D=3&data%5Bfrom%5D=Alpha&data%5Btext%5D=Hello+%7Bname%7D%21+Your+balance+by+%7Bdate%7D+is+%7Bbalance%7D%7Bcurrency%7D.";
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.gmbh/service/campaign/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.gmbh');
// API method call
if ($api->call(
'campaign',
'create',
array(
//campaign parameters
'data' => array(
//campaign type
'type' => '3',
//sender ID
'from' => 'Alpha',
//message text
'text' => 'Hello {name}! Your balance by {date} is {balance}{currency}.'
)
)
)
) {
// 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.gmbh/service/Campaign/Delete
You can delete the campaign, which has not yet started, but if the campaign was postponed, there should be not less than 5 minutes left till start.
Parameter | Type | Description |
---|---|---|
id | integer | Campaign ID |
boolean true - if the deletion was successfully completed
Code | Description |
---|---|
2 | If the campaign with specified ID was not found |
10 | If the campaign with specified ID can't be deleted |
curl -X POST \
'https://api.mobizon.gmbh/service/campaign/delete?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK' \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'id=123'
var data = "id=123";
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.gmbh/service/campaign/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.gmbh');
// API method call
if ($api->call(
'campaign',
'delete',
array(
//campaign ID
'id' => '123'
)
)
) {
// 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.gmbh/service/Campaign/Get
Parameter | Type | Description |
---|---|---|
id | integer | Campaign ID |
Data array
Field | Type | Description |
---|---|---|
name | string | Campaign name |
text | string | Full message text or template text with placeholders, which will later be replaced with a unique text for each message |
msgType | string | Campaign message type, at the moment only SMS is supported |
from | string | Sender's signature |
rateLimit | integer | Sending limit by the quantity |
ratePeriod | integer | Sending limit for the time period. To be ignored, if rateLimit is not set or equals to 0 |
deferredToTs | string | Date and time of the campaign, when it is necessary to start sending in the specified time. It should start not later than in 14 days and not earlier than in an hour from the actual time. Format: 2013-12-31 15:34:55 |
mclass | integer | 0, 1, 2, 3, by default 1 - messages are saved to the Incoming messages folder in the phone, 0 - are displayed as a popup and are not saved (flashSMS), is supported not by all phones, 2 - are saved to SIM-card, 3 - SIM Toolkit SMS |
ttl | integer | Message lifetime in minutes makes from 1 min to 3 days (4320 min) from the moment of sending (the parameter is only available for SMS campaigns) |
curl -X POST \
'https://api.mobizon.gmbh/service/campaign/get?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK' \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'id=123'
var data = "id=123";
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.gmbh/service/campaign/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.gmbh');
// API method call
if ($api->call(
'campaign',
'get',
array(
//campaign ID
'id' => '123'
)
)
) {
// 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.gmbh/service/Campaign/GetInfo
It is used to obtain preliminary information about the cost of the campaign, taking into account the current situation in the system, as well as to obtain information on the number of sent and delivered messages, the amount of money spent and other statistics related to the campaign.
IMPORTANT! Because of the campaign's calculation technical features, data on the preliminary cost of the campaign are specified at the time of recipients' adding and do not change over time, unless you upload the recipients again or edit the campaign data (if you edit the data, all recipients and calculations will be reset and reloading will be necessary).
Parameter | Type | Description |
---|---|---|
id | integer | Campaign ID |
getFilledTplCampaignText | bool | 1 - to return the text of the template campaign filled out with real recipient data, by default 0 - campaign's text containing placeholders |
Field | Type | Description |
---|---|---|
name | string | Campaign name |
text | string | Full message text, or template text with placeholders, which will later be replaced with a unique text for each message |
msgType | string | Campaign message type, at the moment only SMS is supported |
from | string | Sender's signature |
rateLimit | integer | Sending limit by the quantity |
ratePeriod | integer | Sending limit for the time period. To be ignored, if rateLimit is not set or equals 0 |
deferredToTs | string | Date and time of the campaign, when it is necessary to start sending in the specified time. It should start not later than in 14 days and not earlier than in an hour from the current time. Format: 2013-12-31 15:34:55 |
mclass | integer | 0, 1, 2, 3, by default 1 - messages are saved to the Incoming messages folder in the phone, 0 - are displayed as a popup and are not saved (flashSMS), is supported not by all phones, 2 - are saved to SIM-card, 3 - SIM Toolkit SMS |
ttl | integer | Message expiration time in minutes makes from 1 min to 3 days (4320 min) from the moment of sending (the parameter is only available for SMS campaigns) |
counters | object | Different campaign counters. See below for details |
counters
object fieldsField | Type | Description |
---|---|---|
updateTs | datetime | Last counters update time. Format: 2013-12-31 15:34:55 |
totalNewSegNum | integer | Total number of segments with NEW status |
totalAcceptdSegNum | integer | Total number of segments with ACCEPTD status |
totalDelivrdSegNum | integer | Total number of segments with DELIVRD status |
totalRejectdSegNum | integer | Total number of segments with REJECTD status |
totalExpiredSegNum | integer | Total number of segments with EXPIRED status |
totalUndelivSegNum | integer | Total number of segments with UNDELIV status |
totalDeletedSegNum | integer | Total number of segments with DELETED status |
totalUnknownSegNum | integer | Total number of segments with UNKNOWN status |
totalPdlivrdSegNum | integer | Total number of segments with PDLIVRD status |
totalSegNum | integer | Total number of segments in the campaign. Updates when processing (before sending) messages/campaign segments. |
totalNewMsgNum | integer | Total number of messages with NEW status |
totalAcceptdMsgNum | integer | Total number of messages with ACCEPTD status |
totalDelivrdMsgNum | integer | Total number of messages with DELIVRD status |
totalRejectdMsgNum | integer | Total number of messages with REJECTD status |
totalExpiredMsgNum | integer | Total number of messages with EXPIRED status |
totalUndelivMsgNum | integer | Total number of messages with UNDELIV status |
totalDeletedMsgNum | integer | Total number of messages with DELETED status |
totalUnknownMsgNum | integer | Total number of messages with UNKNOWN status |
totalPdlivrdMsgNum | integer | Total number of messages with PDLIVRD status |
totalMsgNum | integer | Total number of messages (not segments). Updates when processing (before sending) messages/campaign segments. |
totalNewMsgCost | float | Total cost of all segments with NEW status |
totalAcceptdMsgCost | float | Total cost of all segments with ACCEPTD status |
totalDelivrdMsgCost | float | Total cost of all segments with DELIVRD status |
totalRejectdMsgCost | float | Total cost of all segments with REJECTD status |
totalExpiredMsgCost | float | Total cost of all segments with EXPIRED status |
totalUndelivMsgCost | float | Total cost of all segments with UNDELIV status |
totalDeletedMsgCost | float | Total cost of all segments with DELETED status |
totalUnknownMsgCost | float | Total cost of all segments with UNKNOWN status |
totalPdlivrdMsgCost | float | Total cost of all segments with PDLIVRD status |
totalCost | float | Total cost of all segments of the campaign. Updates when processing (before sending) messages/campaign segments. |
recipientsRejected | integer | Number of rejected recipients (not included in the campaign). Updates when processing (before sending) messages/campaign segments. |
curl -X POST \
'https://api.mobizon.gmbh/service/campaign/getInfo?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK' \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'id=123'
var data = "id=123";
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.gmbh/service/campaign/getInfo?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.gmbh');
// API method call
if ($api->call(
'campaign',
'getInfo',
array(
//campaign ID
'id' => '123'
)
)
) {
// 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.gmbh/service/Campaign/GetLinks
Parameter | Type | Description |
---|---|---|
campaignId | integer | Campaign ID |
Data array for each link
Field | Type | Description |
---|---|---|
id | integer | Link ID |
code | string | Short link code |
fullLink | string | Full link |
shortLink | string | Short link |
clickCnt | integer | Number of clicks |
redirectCnt | integer | Number of transitions |
comment | string | Comment |
Code | Description |
---|---|
2 | If the campaign was not found. |
curl -X POST \
'https://api.mobizon.gmbh/service/campaign/getLinks?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK' \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'campaignId=123'
var data = "campaignId=123";
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.gmbh/service/campaign/getLinks?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.gmbh');
// API method call
if ($api->call(
'campaign',
'getLinks',
array(
//campaign ID
'campaignId' => '123'
)
)
) {
// 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.gmbh/service/Campaign/List
If the filter by campaign creation date or the launch date is not set, then the system automatically sets the filter by creation date for the last 24 hours from the current time(from 00:00:00 of the last 24 hours to the current moment by the user's time). The maximum sampling interval by creation date/launch date makes 90 days when trying to search for a longer interval only the results for the last 90 days before the date of the end of the search interval will return. If you set the start date or the end date only, the second date will be calculated and installed automatically at a distance of 90 days from the set one. If the date range is invalid (the end date is greater than the start date), then the result will be empty. When installing only dates, the time is set automatically - for start dates to 00:00:00
, and for end dates to 23:59:59
according to user timezone settings.
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 |
---|---|---|
criteria[id] | integer | Search for # campaign (if this parameter is set, then the compulsory limit by creation date is not used and the search is performed on all campaigns ever created) |
criteria[ids] | array | Search for campaign IDs, the parameter should be passed as an array or IDs string, separated by commas, maximum IDs number makes 10, if this limit is exceeded, the search will occur on the first 10 from the list. (if this parameter is set, then the compulsory limit by creation date is not used and the search is performed on all campaigns ever created) |
criteria[recipient] | string | Search for recipient's number |
criteria[from] | string | Search for sender's signature (alfaname) |
criteria[text] | string | Search for text of the campaign |
criteria[status] | string | Search for campaign status; the list of possible statuses see in documentation |
criteria[createDateFrom] | string | Search for campaign creation date, starting from the specified date (date format YYYY-MM-DD ) |
criteria[createTimeFrom] | string | Search for campaign creation date, starting from the specified date, taking into account the exact time on this day (time format HH:MM:SS ) - if the date is not specified, this field is to be ignored |
criteria[createDateTo] | string | Search for campaign creation date before the specified date (date format YYYY-MM-DD ) |
criteria[createTimeTo] | string | Search for campaign creation date before the specified date, taking into account the exact time on this day (time format HH:MM:SS ) - if the date is not specified, this field is to be ignored |
criteria[sentDateFrom] | string | Search for campaign launch date, starting from the specified date (date format YYYY-MM-DD ) |
criteria[sendTimeFrom] | string | Search for campaign launch date, starting from the specified date, taking into account the exact time on this day (time format HH:MM:SS ) - if the date is not specified, this field is to be ignored |
criteria[sentDateTo] | string | Search for campaign launch date before the specified date (date format YYYY-MM-DD ) |
criteria[sentTimeTo] | string | Search for campaign launch date before the specified date, taking into account the exact time on this day (time format HH:MM:SS ) - if the date is not specified, this field is to be ignored |
criteria[type] | integer | Search for campaign type; the list of available campaign types see in documentation |
Parameter | Type | Description |
---|---|---|
pagination[pageSize] | integer | Number of visible elements on the page |
pagination[currentPage] | integer | Current page |
Parameter | Type | Description |
---|---|---|
sort[id] | integer | Campaign ID |
sort[recipient] | string | Recipient's number |
sort[from] | string | Sender's signature |
sort[text] | string | Campaign text |
sort[status] | string | Campaign status |
sort[type] | integer | Campaign type |
Data array
Field | Type | Description |
---|---|---|
items | array | List of found campaigns (see Campaigns' list) |
totalItemCount | integer | Total number of the elements found |
Every campaign contains the following fields:
Field | Type | Description |
---|---|---|
userId | integer | User ID |
partnerId | integer | Partner ID |
type | integer | Campaign type |
name | string | Campaign name |
msgType | integer | Message type |
from | string | Sender's signature |
text | string | Message text or template in case of template campaign |
startTs | string | Campaign start time |
createTs | string | Time of creation |
rateLimit | integer | Sending limit by quantity |
ratePeriod | integer | Time period for quantity limit |
status | integer | Current campaign status. See List of possible campaign statuses for details. |
creationWay | integer | Method of campaign creation: 1 - WEB ,3 - SMPP , 5 - system (e.g. SMS with confirmation code for the form) |
isDeleted | integer | Campaign deleted: 1 - yes , 0 - no |
extra | string | Serialized parameters' value (udh , ttl , mclass ) |
groups | string | Campaign recipients' groups |
counters | object | Different campaign counters. See below for details |
##### counters
object fields
Field | Type | Description |
---|---|---|
updateTs | datetime | Last counters update time. Format: 2013-12-31 15:34:55 |
totalNewSegNum | integer | Total number of segments with NEW status |
totalAcceptdSegNum | integer | Total number of segments with ACCEPTD status |
totalDelivrdSegNum | integer | Total number of segments with DELIVRD status |
totalRejectdSegNum | integer | Total number of segments with REJECTD status |
totalExpiredSegNum | integer | Total number of segments with EXPIRED status |
totalUndelivSegNum | integer | Total number of segments with UNDELIV status |
totalDeletedSegNum | integer | Total number of segments with DELETED status |
totalUnknownSegNum | integer | Total number of segments with UNKNOWN status |
totalPdlivrdSegNum | integer | Total number of segments with PDLIVRD status |
totalSegNum | integer | Total number of segments in the campaign. Updates when processing (before sending) messages/campaign segments. |
totalNewMsgNum | integer | Total number of messages with NEW status |
totalAcceptdMsgNum | integer | Total number of messages with ACCEPTD status |
totalDelivrdMsgNum | integer | Total number of messages with DELIVRD status |
totalRejectdMsgNum | integer | Total number of messages with REJECTD status |
totalExpiredMsgNum | integer | Total number of messages with EXPIRED status |
totalUndelivMsgNum | integer | Total number of messages with UNDELIV status |
totalDeletedMsgNum | integer | Total number of messages with DELETED status |
totalUnknownMsgNum | integer | Total number of messages with UNKNOWN status |
totalPdlivrdMsgNum | integer | Total number of messages with PDLIVRD status |
totalMsgNum | integer | Total number of messages (not segments). Updates when processing (before sending) messages/campaign segments. |
totalNewMsgCost | float | Total cost of all segments with NEW status |
totalAcceptdMsgCost | float | Total cost of all segments with ACCEPTD status |
totalDelivrdMsgCost | float | Total cost of all segments with DELIVRD status |
totalRejectdMsgCost | float | Total cost of all segments with REJECTD status |
totalExpiredMsgCost | float | Total cost of all segments with EXPIRED status |
totalUndelivMsgCost | float | Total cost of all segments with UNDELIV status |
totalDeletedMsgCost | float | Total cost of all segments with DELETED status |
totalUnknownMsgCost | float | Total cost of all segments with UNKNOWN status |
totalPdlivrdMsgCost | float | Total cost of all segments with PDLIVRD status |
totalCost | float | Total cost of all segments of the campaign. Updates when processing (before sending) messages/campaign segments. |
recipientsRejected | integer | Number of rejected recipients (not included in the campaign). Updates when processing (before sending) messages/campaign segments. |
Status | Description |
---|---|
NEW | The campaign has been created, but the user has not yet sent it. Adding recipients is allowed in this status. |
MODERATION | Waiting for the moderator to check for compliance with the service rules. |
DECLINED | Rejected by the moderator because it does not comply with the service rules or the requirements of operators whose numbers are present in the campaign. |
READY_FOR_SEND | The campaign is accepted and will be sent. |
AUTO_READY_FOR_SEND | The campaign does not need moderation and will be sent. |
NOT_YET_SENT | Status for the search. Includes all statuses while a campaign has not yet been sent. Campaigns cannot have this status. |
RUNNING | The campaign is being sent. |
DEFERRED | Campaign is deferred and will be sent at the specified time. |
SENT | All messages have been sent to operators and are waiting for statuses. |
DONE | All statuses have been received or reached the maximum status pending time for all SMS and statuses have not been received (default is 24 hours). Once this status is set, no campaign counters are changed. |
curl -X POST \
'https://api.mobizon.gmbh/service/campaign/list?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK' \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'criteria%5Bfrom%5D=Alpha&pagination%5BcurrentPage%5D=2&pagination%5BpageSize%5D=50&sort%5Btype%5D=ASC'
var data = "criteria%5Bfrom%5D=Alpha&pagination%5BcurrentPage%5D=2&pagination%5BpageSize%5D=50&sort%5Btype%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.gmbh/service/campaign/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.gmbh');
// API method call
if ($api->call(
'campaign',
'list',
array(
//search criteria
'criteria' => array(
//alphanumeric sender ID
'from' => 'Alpha'
),
//pagination parameters
'pagination' => array(
//current page
'currentPage' => '2',
//number of displayed items per page
'pageSize' => '50'
),
//sorting parameters
'sort' => array(
//sorting by campaign type ascending
'type' => '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.gmbh/service/Campaign/Send
Depending on the moderation flags of the user, who created the campaign, it will end up on moderation or will be immediately queued for sending
Parameter | Type | Description |
---|---|---|
id | integer | Campaign ID |
integer campaign status: 1 - moderation, 2 - sending
Code | Description |
---|---|
2 | If the campaign was not found. |
10 | If campaign status failed to change. |
curl -X POST \
'https://api.mobizon.gmbh/service/campaign/send?output=json&api=v1&apiKey=KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK' \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'id=123'
var data = "id=123";
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.gmbh/service/campaign/send?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.gmbh');
// API method call
if ($api->call(
'campaign',
'send',
array(
//campaign ID
'id' => '123'
)
)
) {
// 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;
}