PHP code example of indiana-university / iukb-api-php

1. Go to this page and download the library: Download indiana-university/iukb-api-php 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/ */

    

indiana-university / iukb-api-php example snippets




use \Edu\Iu\Uits\KnowledgeBase\Provider\Filesystem\Filesystem;

$provider = new Filesystem(__dir__ . '/kbCache/');



use \Edu\Iu\Uits\KnowledgeBase\Provider\Web\Web;

$provider = new Web('https://rest.kb.iu.edu', 'username', 'password');



use \Edu\Iu\Uits\KnowledgeBase\KnowledgeBase;
use \Edu\Iu\Uits\KnowledgeBase\Provider\Web\Web;

$provider = new Web('https://rest.kb.iu.edu', 'username', 'password');

$kb = new KnowledgeBase($provider);



use \Doctrine\Common\Cache\ApcuCache;
use \Edu\Iu\Uits\KnowledgeBase\KnowledgeBase;
use \Edu\Iu\Uits\KnowledgeBase\Provider\{
    Caching\Caching,
    Web\Web,
};

$kb_provider = new Web('https://rest.kb.iu.edu', 'username', 'password');
$cache = new ApucCache();
$provider = new Caching($kb_provider, $cache);

$kb = new KnowledgeBase($provider);

$doc = $kb->getDocument('rest');
echo $doc->getContent();

$search = $kb->getSearch('outlook');
foreach ($search->getResults() as $result) {
    echo "[{$result->getDocid()}] {$result->getTitle()}" . PHP_EOL;
}