Ejemplo n.º 1
0
<?php

require 'vendor/autoload.php';
use Sajari\Engine\EngineClient;
use Sajari\Engine\Exception\EngineException;
$logger = new Monolog\Logger('log');
$logger->pushHandler(new Monolog\Handler\StreamHandler('php://stdout'));
$c = new EngineClient(new Guzzle\Http\Client(), array('access_key' => getenv('SAJARI_ACCESS_KEY'), 'secret_key' => getenv('SAJARI_SECRET_KEY'), 'company' => getenv('SAJARI_COMPANY'), 'collection' => getenv('SAJARI_COLLECTION')), $logger);
try {
    $r = $c->autocomplete(array('q' => getenv('QUERY')));
    echo var_export($r, true), PHP_EOL;
} catch (EngineException $e) {
    echo 'There was an error running the autocomplete. ', $e->getMessage(), PHP_EOL;
}