New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

acquia/perz-api-php

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acquia/perz-api-php

A PHP Client library to consume the CIS API.

Source
Packagist
This package is abandoned and is no longer maintained.
The author recommends using true instead.
This version has been yanked by its maintainers and should not be used.
Version
0.1.5
Version published
Total downloads
435K
Maintainers
1
Created
Source

Acquia Personalization API Client for PHP

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

Installation

Install the latest version with Composer:

$ composer require acquia/perz-api-php

Usage

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 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.
   *
   * @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.

<?php
/**
 * Get entities from Personalisation.
 *
 * @param array $data
 *   An array of Entity data.
 *   $data = [
 *     'account_id' => (string) Acquia Account ID. Required.
 *     'origin' => (string) Site ID. Required.
 *     'environment' => (string) Site environment. Required.
 *     'language' => (string) Entity Language. Optional.
 *     'view_mode' => (string) View mode of Entity. Optional.
 *     'q' => (string) Keywords to search. Optional.
 *     'content_type' => (string) Type of the Entity. Oprional.
 *     'tags' =>  (string) Tags to search, Optional.
 *     'all_tags' => (string) All tags to search. Optional.
 *     'date_start' => (datetime) Start date of Entity update. Optional.
 *     'date_end' => (datetime) End date of Entity update. Optional.
 *     'rows' => (integer) Number of rows in result. Default 10. Optional.
 *     'start' => (integer) Page start index. Default 0. Optional.
 *     'sort' => (string) Sort by field. Default modified. Optional.
 *     'sort_order' => (string) Sort order. Default desc. 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);

FAQs

Package last updated on 09 Feb 2024

Related posts