diff --git a/src/Client.php b/src/Client.php index 81f45a7..b013d95 100644 --- a/src/Client.php +++ b/src/Client.php @@ -18,6 +18,7 @@ class Client private $http; private $id; private $collector; + private $headers; public function __construct(array $params, HttpClient $http = null) { @@ -30,14 +31,21 @@ public function __construct(array $params, HttpClient $http = null) $this->http = !is_null($http) ? $http : new HttpClient(); $this->apiKey = $params['api_key']; $this->endpoint = $params['endpoint']; + + $this->headers = (isset($_SERVER['HTTP_USER_AGENT'])) ? [ + 'User-Agent' => $_SERVER['HTTP_USER_AGENT'] + ] : []; } public function search(Query $query) { $endpoint = "{$this->endpoint}/search?api-key={$this->apiKey}"; $response = $this->http->request('POST', $endpoint, [ + 'headers' => $this->headers, 'form_params' => [ - 'q' => $query->toJson() + 'q' => $query->toJson(), + 'version' => 'php 1.0.0', + 'id' => $this->id ] ]); diff --git a/src/Traits/GeneratesUniqueId.php b/src/Traits/GeneratesUniqueId.php index 6c44c32..bf72ff4 100644 --- a/src/Traits/GeneratesUniqueId.php +++ b/src/Traits/GeneratesUniqueId.php @@ -6,6 +6,6 @@ trait GeneratesUniqueId { public function generateUniqueId($prefix = '') { - return substr(str_replace('.', '', uniqid($prefix, true) . str_shuffle('abcdefghjkmnpqrstvwxyz0123456789')), 0, 24); + return substr(str_replace('.', '', uniqid($prefix, true) . str_shuffle('abcdefghjklmnopqrstuvwxyz0123456789')), 0, 24); } }