PHP Client

Please download latest version of PHP client for Loorex API.

Access token can be created at API keys page of your profile.

Please refer to individual method pages to get explanation of all supported fields.

Example

	require_once 'loorex_api_base.php';
	require_once 'loorex_api_exam.php';

	$client = new LoorexApiExam($AccessToken);

	// Create new exam
	$params = [
		'title'		=> 'Using Loorex Software',
		'category'	=> 'Loorex',
		'code'		=> 'LR-001',
	];
	$ExamId = $client->examCreate($params);

	// Update exam
	$params['id']	= $ExamId;
	$params['title']= 'Using Loorex Software Updated';
	$bool = $client->examUpdate($params);

	// Create new question
	$params = [
		'question'	=> [
			'test_id'		=> $ExamId,
			'question'		=> '
Which files types are supported by import wizard? (Choose all that apply)', 'type' => _LOOREX_QT_MULTISELECT, ], 'answers' => [ [ 'answer' => 'DOCX', 'is_correct' => false, ], [ 'answer' => 'PDF', 'is_correct' => true, ], [ 'answer' => 'TXT', 'is_correct' => true, ], [ 'answer' => 'XPS', 'is_correct' => true, ], [ 'answer' => 'XLS', 'is_correct' => false, ], [ 'answer' => 'VCS', 'is_correct' => false, ] ] ]; // Add /img/mobile.png image content to request $params['resources']['/img/mobile.png'] if (!$client->loadMediaFile($params, '/img/mobile.png', 'https://loorex.com/img/mobile.png')) { // Resource was not loaded, do required action } $QuestionId = $client->questionCreate($params); // Get extended response $extResponse= $client->getExtendedResponse(); // Print errors if any if ($client->getIsErrors()) { print_r($client->getErrors()); } // Update question // It is not necessary to send resources in update request if new media resources was not introduced // However, please be aware that Loorex changes relative URLs of uploaded media files unset($params['resources']); $params['question']['id'] = $QuestionId; $params['question']['question'] = $extResponse['question']['question'] . '
Updated'; $bool = $client->questionUpdate($params); if ($client->getIsErrors()) { print_r($client->getErrors()); } // Get exam list $examIds = $client->examList(); if (is_array($examIds)) { foreach ($examIds as $examValue) { $ExamId = $examValue['id']; // Get exam information $ExamInfo = $client->examGet($ExamId); // May have not full access to exam if ($ExamInfo && !$client->getIsErrors()) { print_r($ExamInfo); // Get question list $QuestionList = $client->questionList($ExamId); if (is_array($QuestionList)) { foreach ($QuestionList as $questionValue) { $QuestionId = $questionValue['id']; // Get question information $QuestionInfo = $client->questionGet($ExamId, $QuestionId); print_r($QuestionInfo); } } } } } // Delete exam $client->examDelete($ExamId);