PHP code example of deboorn / ccb-api
1. Go to this page and download the library: Download deboorn/ccb-api 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/ */
deboorn / ccb-api example snippets
$ccb = new \CCB\Api('username', 'password', 'https://yourdomain.ccbchurch.com/api.php');
# Example 1 -- How to fetch and loop over api data
// fetch transaction detail type list
$response = $ccb->fetch('transaction_detail_type_list');
// loop over results (if any)
if ($response['transaction_detail_types']->attr('count') > 0) {
foreach ($response['transaction_detail_type'] as $element) {
$item = pq($element);
var_dump($item['name']->text());
}
}
# Example 2 -- How to build and post xml body data to api
// get model from local file /ccb/templates/import_online_gifts.xml
// you could also skip this and build your xml string directly
// add your own templates by saving them from the api docs to the template directory
$model = $ccb->fromTemplate('srv_endpoint_string');
$model['element_name']->text('value');
// ...
$response = $ccb->fetch('srv_endpoint_string', $model, 'POST');
var_dump($response);
# Example 3 -- How to build and send GET data to api
$params = array(
// h('online_giving_insert_gift', $params);
var_dump($response['gift_id']->text());
} catch (\CCB\Exception $e) {
var_dump($e->getMessage(), $e->getCode(), $e->getXml());
}