🟰Additional Headers
School ID
For API calls that are specific to one school, the School ID needs to be provided in the request headers. See the Get Client Integrations call for a list of your available School IDs.
Specify the school ID using:
HTTP-X-SCHOOLID
Sample Code
<?php
// API Credentials
$api_username = 'your_username';
$api_password = 'your_password';
$school_id = 'the_school_id';
// Base API endpoint
define('BASE_URL', 'https://integrate.d6plus.co.za/api/v2/learners');
// Optional: Set an ID to fetch a specific learner (or leave empty for all)
$id = '';
$url = BASE_URL;
if (!empty($id)) {
$url .= '/' . $id;
}
// Initialize cURL
$curl = curl_init();
// Set cURL options
curl_setopt_array($curl, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30, // Set timeout to prevent hanging requests
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => [
"HTTP-X-USERNAME: $api_username",
"HTTP-X-PASSWORD: $api_password",
"HTTP-X-SCHOOLID: $school_id"
],
]);
// Execute request
$response = curl_exec($curl);
// Check for errors
$error = curl_error($curl);
if ($error) {
curl_close($curl);
throw new Exception("cURL Error: $error");
}
// Close cURL and output response
curl_close($curl);
echo $response;
Last updated