PHP code example of stevenbuehner / sb-churchtools-api
1. Go to this page and download the library: Download stevenbuehner/sb-churchtools-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/ */
stevenbuehner / sb-churchtools-api example snippets
use GuzzleHttp\Cookie\CookieJar;
use StevenBuehner\ChurchTools\Api\PersonApi;
use StevenBuehner\ChurchTools\ApiException;
use StevenBuehner\ChurchTools\Configuration;
use StevenBuehner\ChurchToolsApi\ChurchToolsUserAuthenticatedClient;
// Create Config
$config = Configuration::getDefaultConfiguration();
$config->setHost('https://slug.church.tools/api');
$config->setUsername('username');
$config->setPassword('password');
// Create Client with Autthentication
$cookieJar = new CookieJar();
$client = new ChurchToolsUserAuthenticatedClient($config, $cookieJar);
$success = $client->login();
// $client->logout();
$personApi = new PersonApi($client, $config);
try {
$test = $personApi->getAllPersons()->getData();
} catch (ApiException $e) {
}
uzzleHttp\Cookie\CookieJar;
use StevenBuehner\ChurchTools\Api\GroupApi;
use StevenBuehner\ChurchTools\Api\PersonApi;
use StevenBuehner\ChurchTools\ApiException;
use StevenBuehner\ChurchTools\Configuration;
use StevenBuehner\ChurchToolsApi\ChurchToolsTokenAuthenticatedClient;
use StevenBuehner\ChurchToolsApi\ChurchToolsUserAuthenticatedClient;
// Create Config
$config = Configuration::getDefaultConfiguration();
$config->setHost('https://slug.church.tools/api');
$config->setAccessToken('token');
// Create Client with Token
$cookieJar = new CookieJar();
$client = new ChurchToolsTokenAuthenticatedClient($config, $cookieJar);
$success = $client->login(); // Not neccessary with token
// $client->logout(); // For cleanup
// Create an api
$groupApi = new GroupApi($client, $config);
$personApi = new PersonApi($client, $config);
// ...
// Iteration Example
$hasMore = TRUE;
$page = 1;
$limit = 100;
while ($hasMore === TRUE) {
try {
$response = $personApi
->getAllPersons(NULL, NULL, NULL, NULL, NULL, FALSE, $page, $limit);
} catch (ApiException $e) {
}
// do Something with persons ...
// get next batch of persons
$hasMore = $response->getMeta()->getPagination()->getLastPage() > $page;
$page++;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.