PHP code example of kaigan / qbankapi2wrapper
1. Go to this page and download the library: Download kaigan/qbankapi2wrapper library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kaigan / qbankapi2wrapper example snippets
QBankAPIFactory::setup(QBANK_ADDRESS, USERNAME, PASSWORD);
try {
$searchAPI = QBankAPIFactory::createAPI(QBankAPIFactory::SearchAPI);
} catch (QBankAPIException $qae) {
// Handle the error
}
$searchAPI = new QBankSearchAPI(QBANK_ADDRESS);
if ($objectAPI->login(USERNAME, PASSWORD) !== true) {
// Handle faulty login
} else {
$qbankSessionHash = $objectAPI->getHash();
// Save the session hash somewhere
}
$searchAPI = new QBankSearchAPI(QBANK_ADDRESS);
$objectAPI = new QBankObjectAPI(QBANK_ADDRESS);
if ($objectAPI->login(USERNAME, PASSWORD) !== true) {
// Handle faulty login
} else {
$qbankSessionHash = $objectAPI->getHash();
$objectAPI->setHash($qbankSessionHash);
// Save the session hash somewhere
}
QBankAPIFactory::setup(QBANK_ADDRESS, USERNAME, PASSWORD);
try {
$searchAPI = QBankAPIFactory::createAPI(QBankAPIFactory::SearchAPI);
$search = new Search();
$search->setFreeText('string to search for');
$results = $searchAPI->execute($search);
// Display the results
} catch (QBankAPIException $qae) {
// Handle the error
}
QBankAPIFactory::setup(QBANK_ADDRESS, USERNAME, PASSWORD);
try {
$searchAPI = QBankAPIFactory::createAPI(QBankAPIFactory::SearchAPI);
$search = new Search();
$properties = array();
$properties[] = new PropertyRequest(PROPERTY_SYSTEM_NAME);
$search->addPropertyCriterias($properties);
$results = $searchAPI->execute($search);
// Display the results
} catch (QBankAPIException $qae) {
// Handle the error
}
$results = $searchApi->execute($search);
$firstResult = $results[0];
foreach($results as $result) {
echo $result->getId();
}