03.1.2. Demo Function

Accessing staffITpro Data

Once an access token is obtained and saved into a variable, you can use it to access staffITpro data via the API by composing an HTTP request as follows:

BaseAPIUrl + /Module/EndPoint

All Endpoints can be found here.

Include the Access Token

The access token can be included in the request via the Authorization request header:

SIP sip_token={TOKEN}

Example: Candidate count

function CandidateCount() 
{
    GLOBAL $api_url;

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $api_url . 'Candidate/count');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Accept: application/json',
        'Content-Type: application/json',
        'Authorization: SIP sip_token='.$_SESSION['token'] //Token required
    ));
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}

Example: Candidate privacy

function CandidatePrivacyCreate() 
{
    GLOBAL $api_url;

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $api_url . 'Candidate/Privacy');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Accept: application/json',
        'Content-Type: application/json',
        'Authorization: SIP sip_token='.$_SESSION['token'] //Token required
    ));
    $postFields->CandidateExpirationUpdateType = 3;
    $postFields->Action = 5;
    $postFields->Type = 5;
    $postFields->CandidateId = 15;
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postFields));
    curl_setopt($ch, CURLOPT_POST, 1);

    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}