searchili/searchili-client-php

Client for SearChili search services

1.1 2020-12-20 16:24 UTC

This package is auto-updated.

Last update: 2024-05-26 02:24:27 UTC


README

PHP client for SearChili API

Build Status Packagist Latest Stable Version License

Requirements

  • PHP 5.6+
  • Autoloader compatible with PSR-4
  • PHP must be compiled with lib-curl

Installation

To install the library just add it via composer

composer require SearChili/searchili-client-php

Or in composer.json

{
    "SearChili/searchili-client-php": "^1.0"
}

Tests

We can use the composer to run the tests:

composer test

How to Use

To use this library, you must first register on SearChili. After the registration, an apiKey and apiSecret will be available to access the API.

The API methods that can be invoked:

  • Site info
  • Entity search
  • Entity sayt
  • Entity store
  • Entity delete

The following is a small example of how this library can be used.

Alice

Search
<?php

require_once "vendor/autoload.php";

use SearChili\Alice\Client as SearChiliAliceClient;

$client = new SearChiliAliceClient('<apiKey>');

$entities = $client->entity->search('query');
print_r($entities);

Bob

Get authenticated site info
<?php

require_once "vendor/autoload.php";

use SearChili\Bob\Client as SearChiliBobClient;

$client = new SearChiliBobClient('<apiSecret>');

$response = $client->site->get();
print_r($response->toArray());
Store
$result = $aliceClient->entity->store(
    1, // ID
    'Example Title', // Title
    'http://domain.com/article-1', // Link
    'This is excerpt', // Excerpt
    'This will be the long body of this amazing article.' // Body
);
print_r($result);
Delete
$result = $aliceClient->entity->delete(1);
var_dump($result);

License

This library follows the terms of use of MIT