API-Clients

PHP

Mit dem offiziellen PHP-Client kann die REST API von Customa von PHP aus angesprochen werden. Der Client ist als Library tid/customa auf Packagist verfügbar.

Es folgt ein Beispiel für die Nutzung des Clients:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
$config = new Configuration();
$authApi = new AuthApi(config: $config);
$customerApi = new CustomerApi(config: $config);

$authResponse = $authApi->authLogin(new AuthLoginRequest([
    "username" => $username,
    "password" => $password,
    "project" => $project,
]));

$config->setAccessToken($authResponse->getToken());

$searchResponse = $customerApi->customerSearch(new SearchRequest([
    "page" => 1,
    "page_size" => 1,
    "filter" => []
]));

$authApi->authLogout();

echo "{$searchResponse->getTotalCount()} Customers found.\n";