Adds a course to Frontcores database using POST.
- Will return an error if an active course with equal title already exists.
- Kursguiden staff will categorize the course within a few working days.
For every API request you make, you'll need to present the API access key in the HTTP Header as X-API-Key to be authenticated.
| Name | Required | Value | Description |
|---|---|---|---|
| title | required | string | Title of the course |
| active | optional | bool | Default is 1 |
| reference | optional | string | Your own reference, if needed. |
| is_full_time | optional | bool | Default is null (not set) |
| is_part_time | optional | bool | Default is null (not set) |
| level | optional | integer | Default is 6 ("Courses")
|
| form_of_teaching | optional | integer | Default is 1 ("Classroom")
|
| teaching_language | optional | string | Default is no ('no' as in Norwegian)
|
| time_of_day | optional | integer | Default is null (not set)
|
| duration_value | optional | integer | Default is null (not set) |
| duration_unit | optional | integer | Default is null (not set)
|
| price_value | optional | integer | Default is null (not set) |
| price_currency | optional | string | Default is NOK |
| price_comment | optional | string | |
| text_lead | optional | string | ~170 characters are visible on Kursguidens listing pages. |
| text_description | optional | string | Can contain HTML |
| text_place | optional | string | Can contain HTML |
| text_prerequisites | optional | string | Can contain HTML |
| text_duration | optional | string | Can contain HTML |
| text_credits | optional | string | Can contain HTML |
| text_submissions | optional | string | Can contain HTML |
| text_hotel_info | optional | string | Can contain HTML |
| text_audience | optional | string | Can contain HTML |
| email_booking | optional | string | E-mail address |
| email_more_info | optional | string | E-mail address |
$post_params = array();
$post_params['title'] = 'Learn REST API';
$post_params['active'] = '1';
$post_params['reference'] = 'RESTAPI-CA-1001';
$post_params['is_full_time'] = '0';
$post_params['is_part_time'] = '1';
$post_params['level'] = '6';
$post_params['form_of_teaching'] = '1';
$post_params['teaching_language'] = 'no';
$post_params['time_of_day'] = '2';
$post_params['duration_value'] = '6';
$post_params['duration_unit'] = '6';
$post_params['price_value'] = '1500';
$post_params['price_currency'] = 'NOK';
$post_params['price_comment'] = 'Includes a free beer.';
$post_params['text_lead'] = 'REST API is very useful.';
$post_params['text_description'] = '<p>REST API is a easy way of sharing information between sites.</p>';
$post_params['text_place'] = '<p>At IT Fornebu.</p>';
$post_params['text_prerequisites'] = '<p>Normal programming skills.</p>';
$post_params['text_duration'] = '<p>2 sessions. Each session is 3 hours.</p>';
$post_params['text_credits'] = '<p>No credts.</p>';
$post_params['text_submissions'] = '<p>Two tasks to be submitted online.</p>';
$post_params['text_hotel_info'] = '<p>Scandic Fornebu.</p>';
$post_params['text_audience'] = '<p>Programmers and web developers.</p>';
$post_params['email_booking'] = 'booking@exampleschool.no';
$post_params['email_more_info'] = 'more.info@exampleschool.no';
$request_url = 'https://www.kursguiden.no/api/v1/courses';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-API-Key: {your-api-key}',
'Accept: application/json',
));
$result = curl_exec($ch);
curl_close($ch);
If the method is successful it responds with an JSON structure, as it is shown below.
{
"status": "success",
"course_id": "22357"
}
Unsuccessful response sample:
{
"status": "failure",
"error": "Required field 'title' is missing"
}