PHPackages                             acquia/perz-api-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. acquia/perz-api-php

AbandonedArchivedLibrary[API Development](/categories/api)

acquia/perz-api-php
===================

A PHP Client library to consume the CIS API.

0.1.5(2y ago)1436.7k—7.4%GPL-2.0-or-laterPHPPHP &gt;=7.1CI failing

Since Jul 20Pushed 9mo ago9 watchersCompare

[ Source](https://github.com/acquia/perz-api-php)[ Packagist](https://packagist.org/packages/acquia/perz-api-php)[ Docs](https://github.com/acquia/perz-api-php)[ RSS](/packages/acquia-perz-api-php/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (4)Dependencies (12)Versions (15)Used By (0)

Acquia Personalization API Client for PHP
=========================================

[](#acquia-personalization-api-client-for-php)

Provides an API client for PHP applications communicating with the Acquia Personalization API .

Installation
------------

[](#installation)

Install the latest version with [Composer](https://getcomposer.org/):

```
$ composer require acquia/perz-api-php
```

Usage
-----

[](#usage)

#### Create the API Client

[](#create-the-api-client)

```
use Acquia\PerzApiPhp\ObjectFactory;
use Acquia\PerzApiPhp\PerzApiPhpClient;

$base_uri = 'https://personalization.api.endpoint';
$api_key = 'XXXXXX';
$secret_key = 'XXXXXXXXXXXXXXXX';

$key = ObjectFactory::getAuthenticationKey($api_key, $secret_key);
$middleware = ObjectFactory::getHmacAuthMiddleware($key);
$config = ['base_url' => $base_uri];
$api_client =  new PerzApiPhpClient($middleware, $config);
```

#### Create entities in Personalization

[](#create-entities-in-personalization)

```
 /**
   * Create entity in Personalization.
   *
   * @param array $data
   *   An array of Entity data.
   *   $data = [
   *     'account_id' => (string) Acquia Account ID. Required.
   *     'origin' => (string) Site ID. Required.
   *     'environment' => (string) Site envireonment. Required.
   *     'domain' => (string) Site Domain. Required.
   *     'entity_variations' => (array) Entity variation data. Required.
   *     'site_hash' => (string) Site hash. Optional.
   *   ].
   *
   * @return \Psr\Http\Message\ResponseInterface|void
   *   Response.
   *
   * @throws \GuzzleHttp\Exception\GuzzleException
   *   Guzzle Exception.
   */

$response = $api_client->putVariations($data);
```

#### Delete entities from Personalization.

[](#delete-entities-from-personalization)

```
 /**
   * Delete entities from Personalization.
   *
   * @param array $data
   *   An array of Entity data.
   *   $data = [
   *     'account_id' => (string) Acquia Account ID. Required.
   *     'environment' => (string) Site environment. Required.
   *     'origin' => (string) Site ID. Optional.
   *     'content_uuid' => (string) UUID of the entity. Optional.
   *     'language' => (string) UUID of the entity. Optional.
   *     'view_mode' => (string) UUID of the entity. Optional.
   *     'site_hash' => (string) Site hash. Optional.
   *   ].
   *
   * @return \Psr\Http\Message\ResponseInterface|void
   *   Response.
   *
   * @throws \GuzzleHttp\Exception\GuzzleException
   *   Guzzle Exception.
   */

$response = $api_client->getEntities($data);
```

#### Get entities from Personalisation.

[](#get-entities-from-personalisation)

```
