4

View your availability

availability

GET https://cronorg.com/api/v1/availability?login=&password=

loginYour identification code.
passwordYour password.
startdateStart date.
enddateEnd date.

startdate - YYYY-MM-DD, e.g. 2023-01-01. enddate - YYYY-MM-DD, e.g. 2023-12-31.

NOTE: The parameters startdate and enddate are mandatory.

$ curl -D - -X GET "https://cronorg.com/api/v1/availability?login=abcdef&password=ABCDEF&startdate=2023-01-01&enddate=2023-12-31"
{"status":"success","data":{"total_hours":56,"total_days":8,"weeks":{"3":12,"4":28,"5":16},"timeline":[8,4,0,0,8,8,0,8,4,0,0,8,8]}}

Returns your availability from Thursday, January 19, 2023 until Tuesday, January 31, 2023 with 8 hours available Monday till Thursday and 4 hours Friday and one day of absence on Wednesday January 25, 2023.

Click on the clock in the menu bar of your personal home page to edit your availabilities.

Download the code of the sendget function defined in the file sendhttp.php. Copy the file in the space of your application.

NOTE: See the page Call the service API for a description of the sendget function.

Add the file availability.php with the following content:

  1. require_once 'sendhttp.php';
  1. function availability($login, $password, $startdate, $enddate) {

Defines the function availability. $login is your identification code. $password is your password. $startdate specifies the start of the period, $enddate the end of the period. $startdate and $enddate are integers of the type timestamp (Unix timestamp).

  1.     $curl = 'https://cronorg.com/api/v1/availability';

Sets $curl to the URL of the availability action.

  1.     $args = array(
  2.         'login'     => $login,
  3.         'password'  => $password,
  4.         'startdate' => date('Y-m-d', $startdate),
  5.         'enddate'   => date('Y-m-d', $enddate),
  6.     );

Prepares the list of arguments of the GET: the identification code and the password of the user's account, the start date and the end date of the period.

  1.     $response=sendget($curl, $args);

Sends the HTTP request with sendget.

  1.     if (!$response or $response[0] != 200) {
  2.         return false;
  3.     }

If $response is false, the server is unreachable. If $response[0] doesn't contain the HTTP return code 200 Ok, an execution error has occurred. In case of error, availability returns false.

  1.     $r=json_decode($response[2], true);

Decodes the data returned in JSON.

  1.     if ($r['status'] == 'success') {
  2.         return ($r['data']);
  3.     }

Returns the data array if the action has succeeded.

  1.     return false;
  2. }

Returns false in case of error.

EXAMPLE

Assuming you have saved the files sendhttp.php and availability.php in the current directory, run PHP in interactive mode, load the availability function and call it with your identification code and password, the start date and the end date of a period in argument:

$ php -a
php > require_once 'availability.php';
php > print_r(availability('abcdef', 'ABCDEF', strtotime('2023-01-19'), strtotime('2023-01-31')));
Array
(
    [total_hours] => 56
    [total_days] => 8
    [weeks] => Array
        (
            [3] => 12
            [4] => 28
            [5] => 16
        )

    [timeline] => Array
        (
            [0] => 8
            [1] => 4
            [2] => 0
            [3] => 0
            [4] => 8
            [5] => 8
            [6] => 0
            [7] => 8
            [8] => 4
            [9] => 0
            [10] => 0
            [11] => 8
            [12] => 8
        )
)
php > quit
SEE ALSO

Call the service API

Comments

To add a comment, click here.