Registration

Module Taskqueue

Getting information about tasks in the asynchronous task queue

API methods

Getting Background Task Progress
https://api.mobizon.com.br/service/Taskqueue/GetStatus

Getting Background Task Progress

https://api.mobizon.com.br/service/Taskqueue/GetStatus

This method allows you to get the progress of a background task by its ID. Our service uses background tasks so that your processes do not have to wait for the completion of a long request in cases such as:

  • Uploading recipients to an SMS campaign;
  • Importing contacts into the address book;
  • Creating reports on campaigns and messages.
This request should be sent no more than once per second.

Request Parameters

ParameterTypeDescription
idintegerIdentifier of the background task.

Server Response

Data array:

FieldTypeDescription
progressintegerProgress of the task on a scale from 0 to 100%.
statusintegerTask status code:
0 – waiting to start;
1 – in progress;
2 – completed;
3 – rejected.

API Response Codes

CodeDescription
0Background task progress successfully retrieved.
2If the task with the specified identifier is not found.

Examples

curl -X POST \
  'https://api.mobizon.com.br/service/taskqueue/getStatus?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.com.br/service/taskqueue/getStatus?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(
    'taskqueue',
    'getStatus',
    array(
        //background task identifier
        '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;
}