add_cronjob()

Create a cron job.

Signature

add_cronjob(array $parameters): mixed

Parameters

Pass these parameters as KasRequestParams. Every request also requires kas_login, kas_auth_type, and kas_auth_data, as shown in SOAP with PHP.

Name Description Requirement
protocol Cron job protocol: http|https Required
http_url The cron job URL Required
cronjob_comment The cron job comment Required
minute The minute to run: */1-59|0-59|* Required
hour The hour to run: */1-23|1-23|* Required
day_of_month The day of the month to run: 0-31|* Required
month The month to run: * Required
day_of_week The weekday to run: 0-7|* (Sunday = 0 or 7) Required
http_user The HTTP authentication user Optional
http_password The HTTP authentication password Optional
mail_address The email address that receives the confirmation email, RFC 2822 Optional
mail_condition Condition word; if it appears in the script output, no email is sent Optional
mail_subject Use cronjob_comment as the email subject: default|comment Optional Default: default
is_active The cron job is active: Y|N Optional Default: Y

PHP example

<?php

// $sessionToken is returned by KasAuth, see SOAP with PHP.
$parameters = [
    'http_url' => 'example.com/cron.php',
    'minute' => '9',
    'hour' => '8',
    'day_of_month' => '*',
    'month' => '*',
    'day_of_week' => '*',
    'cronjob_comment' => 'comment',
    'http_user' => 'login',
    'http_password' => 'password',
    'mail_address' => 'cronjob@example.com',
    'is_active' => 'Y',
];

try {
    $client = new SoapClient('https://kasapi.kasserver.com/soap/wsdl/KasApi.wsdl');
    $response = $client->KasApi(json_encode([
        'kas_login' => 'w0123456',
        'kas_auth_type' => 'session',
        'kas_auth_data' => $sessionToken,
        'kas_action' => 'add_cronjob',
        'KasRequestParams' => $parameters,
    ]));
    print_r($response);
} catch (SoapFault $fault) {
    echo 'Error: ' . $fault->faultstring;
}

Responses and error codes

  • TRUE the action was carried out
  • missing_parameter a required parameter is missing
  • couldnt_get_kas_ressources
  • day_of_month_or_day_of_week_incorrect
  • day_of_month_syntax_incorrect
  • day_of_week_syntax_incorrect
  • hour_syntax_incorrect
  • http_password_syntax_incorrect
  • protocol_syntax_incorrect
  • http_url_syntax_incorrect
  • http_user_syntax_incorrect
  • is_active_syntax_incorrect
  • mail_address_syntax_incorrect
  • mail_condition_syntax_incorrect
  • max_cronjobs_reached
  • minute_syntax_incorrect
  • month_syntax_incorrect
  • time_not_allowed