PHP code example of collectiveaccess / service-wrapper

1. Go to this page and download the library: Download collectiveaccess/service-wrapper 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/ */

    

collectiveaccess / service-wrapper example snippets


$client = new CollectiveAccessService\ItemService("http://localhost/","ca_objects","GET",1);
$result = $client->request();
print_r($result->getRawData());

$vo_client = new CollectiveAccessService\ModelService("http://localhost/","ca_entities");
$vo_client->setRequestBody(array("types" => array("corporate_body")));
$vo_result = $vo_client->request();

$vo_result->isOk() ? print_r($vo_result->getRawData()) : print_r($vo_result->getErrors());

$vo_client = new CollectiveAccessService\SearchService("http://localhost/","ca_objects","*");
$vo_client->setRequestBody(array(
	"bundles" => array(
		"ca_objects.access" => array("convertCodesToDisplayText" => true),
		"ca_objects.status" => array("convertCodesToDisplayText" => true),
		"ca_entities.preferred_labels.displayname" => array("returnAsArray" => true)
	)
));
$vo_result = $vo_client->request();

$vo_result->isOk() ? print_r($vo_result->getRawData()) : print_r($vo_result->getErrors());

define('__CA_SERVICE_API_USER__', 'administrator');
define('__CA_SERVICE_API_KEY__', 'dublincore');

$o_service = new CollectiveAccessService\ItemService('http://localhost', 'ca_objects', 'GET', 1);
$o_result = $o_service->request();

$o_service = new CollectiveAccessService\ItemService('http://localhost', 'ca_objects', 'GET', 1);
$o_service->setCredentials('administrator', 'dublincore');
$o_result = $o_service->request();

$o_service = new CollectiveAccessService\ItemService('http://localhost', 'ca_objects', 'GET', 1);
$o_result = $o_service->request();

$client = new CollectiveAccessService\ItemService("http://localhost/","ca_objects","GET",1);
$result = $client->setRetries(5)->setRetryDelay(2000)->request();
print_r($result->getRawData());
bash
export CA_SERVICE_API_USER=administrator
export CA_SERVICE_API_KEY=dublincore
php authtest.php