PHP 클래스 AlgoliaSearch\Client

You should instantiate a Client object with your ApplicationID, ApiKey and Hosts to start using Algolia Search API
파일 보기 프로젝트 열기: algolia/algoliasearch-client-php 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$caInfoPath string
$context ClientContext
$curlConstants array
$curlOptions array
$placesEnabled boolean

공개 메소드들

메소드 설명
__construct ( string $applicationID, string $apiKey, array | null $hostsArray = null, array $options = [] ) Algolia Search initialization.
__destruct ( ) Release curl handle.
addUserKey ( array $obj, integer $validity, integer $maxQueriesPerIPPerHour, integer $maxHitsPerQuery, array | null $indexes = null ) : mixed Create a new user key.
batch ( array $requests ) : mixed Send a batch request targeting multiple indices.
buildQuery ( array $args ) : string
copyIndex ( string $srcIndexName, string $dstIndexName ) : mixed Copy an existing index.
deleteIndex ( string $indexName ) : mixed Delete an index.
deleteUserKey ( string $key ) : mixed Delete an existing user key.
disableRateLimitForward ( ) Disable IP rate limit enabled with enableRateLimitForward() function.
doRequest ( ClientContext $context, string $method, string $host, string $path, array $params, array $data, integer $connectTimeout, integer $readTimeout ) : mixed
enableRateLimitForward ( string $adminAPIKey, string $endUserIP, string $rateLimitAPIKey ) Allow to use IP rate limit when you have a proxy between end-user and Algolia.
generateSecuredApiKey ( string $privateApiKey, mixed $query, string | null $userToken = null ) : string Generate a secured and public API Key from a list of query parameters and an optional user token identifying the current user.
getLogs ( integer $offset, integer $length = 10, mixed $type = 'all' ) : mixed Return last logs entries.
getUserKeyACL ( string $key ) : mixed Get ACL of a user key.
initIndex ( string $indexName ) : Index Get the index object initialized (no server call needed for initialization).
initPlaces ( string $appId, string $apiKey, array $hostsArray = null, array $options = [] ) : PlacesIndex
isAlive ( ) Call isAlive.
listIndexes ( ) : mixed List all existing indexes return an object in the form: array( "items" => array( array("name" => "contacts", "createdAt" => "2013-01-18T15:33:13.556Z"), array("name" => "notes", "createdAt" => "2013-01-18T15:33:13.556Z") ) ).
listUserKeys ( ) : mixed List all existing user keys with their associated ACLs.
moveIndex ( string $srcIndexName, string $dstIndexName ) : mixed Move an existing index.
multipleQueries ( array $queries, string $indexNameKey = 'indexName', string $strategy = 'none' ) : mixed This method allows to query multiple indexes with one API call.
request ( ClientContext $context, string $method, string $path, array $params, array $data, array $hostsArray, integer $connectTimeout, integer $readTimeout ) : mixed
setAlgoliaUserToken ( string $token ) It's possible to use the following token to track users that have the same IP or to track users that use different devices.
setConnectTimeout ( integer $connectTimeout, integer $timeout = 30, integer $searchTimeout = 5 ) Change the default connect timeout of 2s to a custom value (only useful if your server has a very slow connectivity to Algolia backend).
setExtraHeader ( string $key, string $value ) Allow to set custom headers.
setForwardedFor ( string $ip ) The aggregation of the queries to retrieve the latest query uses the IP or the user token to work efficiently.
updateUserKey ( string $key, array $obj, integer $validity, integer $maxQueriesPerIPPerHour, integer $maxHitsPerQuery, array | null $indexes = null ) : mixed Update a user key.

보호된 메소드들

메소드 설명
checkCurlOptions ( array $curlOptions ) : array Checks if curl option passed are valid curl options.
getCurlConstants ( ) : array Get all php curl available options.
invalidOptions ( array $curlOptions = [], string $errorMsg = '' ) throw clear Exception when bad curl option is set.

비공개 메소드들

메소드 설명
getPlacesIndex ( ) : PlacesIndex

메소드 상세

__construct() 공개 메소드

Algolia Search initialization.
public __construct ( string $applicationID, string $apiKey, array | null $hostsArray = null, array $options = [] )
$applicationID string the application ID you have in your admin interface
$apiKey string a valid API key for the service
$hostsArray array | null the list of hosts that you have received for the service
$options array

__destruct() 공개 메소드

Release curl handle.
public __destruct ( )

addUserKey() 공개 메소드

Create a new user key.
public addUserKey ( array $obj, integer $validity, integer $maxQueriesPerIPPerHour, integer $maxHitsPerQuery, array | null $indexes = null ) : mixed
$obj array can be two different parameters: The list of parameters for this key. Defined by an array that can contain the following values: - acl: array of string - indices: array of string - validity: int - referers: array of string - description: string - maxHitsPerQuery: integer - queryParameters: string - maxQueriesPerIPPerHour: integer Or the list of ACL for this key. Defined by an array of string that can contains the following values: - search: allow to search (https and http) - addObject: allows to add/update an object in the index (https only) - deleteObject : allows to delete an existing object (https only) - deleteIndex : allows to delete index content (https only) - settings : allows to get index settings (https only) - editSettings : allows to change index settings (https only)
$validity integer the number of seconds after which the key will be automatically removed (0 means no time limit for this key)
$maxQueriesPerIPPerHour integer Specify the maximum number of API calls allowed from an IP address per hour. Defaults to 0 (no rate limit).
$maxHitsPerQuery integer Specify the maximum number of hits this API key can retrieve in one call. Defaults to 0 (unlimited)
$indexes array | null Specify the list of indices to target (null means all)
리턴 mixed

batch() 공개 메소드

Send a batch request targeting multiple indices.
public batch ( array $requests ) : mixed
$requests array an associative array defining the batch request body
리턴 mixed

buildQuery() 공개 정적인 메소드

public static buildQuery ( array $args ) : string
$args array
리턴 string

checkCurlOptions() 보호된 메소드

Checks if curl option passed are valid curl options.
protected checkCurlOptions ( array $curlOptions ) : array
$curlOptions array must be array but no type required while first test throw clear Exception
리턴 array

copyIndex() 공개 메소드

Copy an existing index.
public copyIndex ( string $srcIndexName, string $dstIndexName ) : mixed
$srcIndexName string the name of index to copy.
$dstIndexName string the new index name that will contains a copy of srcIndexName (destination will be overwritten if it already exist).
리턴 mixed

deleteIndex() 공개 메소드

Delete an index.
public deleteIndex ( string $indexName ) : mixed
$indexName string the name of index to delete
리턴 mixed an object containing a "deletedAt" attribute

deleteUserKey() 공개 메소드

Delete an existing user key.
public deleteUserKey ( string $key ) : mixed
$key string
리턴 mixed

disableRateLimitForward() 공개 메소드

Disable IP rate limit enabled with enableRateLimitForward() function.

doRequest() 공개 메소드

public doRequest ( ClientContext $context, string $method, string $host, string $path, array $params, array $data, integer $connectTimeout, integer $readTimeout ) : mixed
$context ClientContext
$method string
$host string
$path string
$params array
$data array
$connectTimeout integer
$readTimeout integer
리턴 mixed

enableRateLimitForward() 공개 메소드

This option will set the X-Forwarded-For HTTP header with the client IP and the X-Forwarded-API-Key with the API Key having rate limits.
public enableRateLimitForward ( string $adminAPIKey, string $endUserIP, string $rateLimitAPIKey )
$adminAPIKey string the admin API Key you can find in your dashboard
$endUserIP string the end user IP (you can use both IPV4 or IPV6 syntax)
$rateLimitAPIKey string the API key on which you have a rate limit

generateSecuredApiKey() 공개 정적인 메소드

Generate a secured and public API Key from a list of query parameters and an optional user token identifying the current user.
public static generateSecuredApiKey ( string $privateApiKey, mixed $query, string | null $userToken = null ) : string
$privateApiKey string your private API Key
$query mixed the list of query parameters applied to the query (used as security)
$userToken string | null an optional token identifying the current user
리턴 string

getCurlConstants() 보호된 메소드

Get all php curl available options.
protected getCurlConstants ( ) : array
리턴 array

getLogs() 공개 메소드

Return last logs entries.
public getLogs ( integer $offset, integer $length = 10, mixed $type = 'all' ) : mixed
$offset integer Specify the first entry to retrieve (0-based, 0 is the most recent log entry).
$length integer Specify the maximum number of entries to retrieve starting at offset. Maximum allowed value: 1000.
$type mixed
리턴 mixed

getUserKeyACL() 공개 메소드

Get ACL of a user key.
public getUserKeyACL ( string $key ) : mixed
$key string
리턴 mixed

initIndex() 공개 메소드

Get the index object initialized (no server call needed for initialization).
public initIndex ( string $indexName ) : Index
$indexName string the name of index
리턴 Index

initPlaces() 공개 정적인 메소드

public static initPlaces ( string $appId, string $apiKey, array $hostsArray = null, array $options = [] ) : PlacesIndex
$appId string
$apiKey string
$hostsArray array
$options array
리턴 PlacesIndex

invalidOptions() 보호된 메소드

throw clear Exception when bad curl option is set.
protected invalidOptions ( array $curlOptions = [], string $errorMsg = '' )
$curlOptions array
$errorMsg string add specific message for disambiguation

isAlive() 공개 메소드

Call isAlive.
public isAlive ( )

listIndexes() 공개 메소드

List all existing indexes return an object in the form: array( "items" => array( array("name" => "contacts", "createdAt" => "2013-01-18T15:33:13.556Z"), array("name" => "notes", "createdAt" => "2013-01-18T15:33:13.556Z") ) ).
public listIndexes ( ) : mixed
리턴 mixed

listUserKeys() 공개 메소드

List all existing user keys with their associated ACLs.
public listUserKeys ( ) : mixed
리턴 mixed

moveIndex() 공개 메소드

Move an existing index.
public moveIndex ( string $srcIndexName, string $dstIndexName ) : mixed
$srcIndexName string the name of index to copy.
$dstIndexName string the new index name that will contains a copy of srcIndexName (destination will be overwritten if it already exist).
리턴 mixed

multipleQueries() 공개 메소드

This method allows to query multiple indexes with one API call.
public multipleQueries ( array $queries, string $indexNameKey = 'indexName', string $strategy = 'none' ) : mixed
$queries array
$indexNameKey string
$strategy string
리턴 mixed

request() 공개 메소드

public request ( ClientContext $context, string $method, string $path, array $params, array $data, array $hostsArray, integer $connectTimeout, integer $readTimeout ) : mixed
$context ClientContext
$method string
$path string
$params array
$data array
$hostsArray array
$connectTimeout integer
$readTimeout integer
리턴 mixed

setAlgoliaUserToken() 공개 메소드

It's possible to use the following token to track users that have the same IP or to track users that use different devices.
또한 보기: https://www.algolia.com/doc/faq/analytics/will-the-analytics-still-work-if-i-perform-the-search-through-my-backend
public setAlgoliaUserToken ( string $token )
$token string

setConnectTimeout() 공개 메소드

Change the default connect timeout of 2s to a custom value (only useful if your server has a very slow connectivity to Algolia backend).
public setConnectTimeout ( integer $connectTimeout, integer $timeout = 30, integer $searchTimeout = 5 )
$connectTimeout integer the connection timeout
$timeout integer the read timeout for the query
$searchTimeout integer the read timeout used for search queries only

setExtraHeader() 공개 메소드

Allow to set custom headers.
public setExtraHeader ( string $key, string $value )
$key string
$value string

setForwardedFor() 공개 메소드

If the queries are made from your backend server, the IP will be the same for all of the queries. We're supporting the following HTTP header to forward the IP of your end-user to the engine, you just need to set it for each query.
또한 보기: https://www.algolia.com/doc/faq/analytics/will-the-analytics-still-work-if-i-perform-the-search-through-my-backend
public setForwardedFor ( string $ip )
$ip string

updateUserKey() 공개 메소드

Update a user key.
public updateUserKey ( string $key, array $obj, integer $validity, integer $maxQueriesPerIPPerHour, integer $maxHitsPerQuery, array | null $indexes = null ) : mixed
$key string
$obj array can be two different parameters: The list of parameters for this key. Defined by a array that can contains the following values: - acl: array of string - indices: array of string - validity: int - referers: array of string - description: string - maxHitsPerQuery: integer - queryParameters: string - maxQueriesPerIPPerHour: integer Or the list of ACL for this key. Defined by an array of string that can contains the following values: - search: allow to search (https and http) - addObject: allows to add/update an object in the index (https only) - deleteObject : allows to delete an existing object (https only) - deleteIndex : allows to delete index content (https only) - settings : allows to get index settings (https only) - editSettings : allows to change index settings (https only)
$validity integer the number of seconds after which the key will be automatically removed (0 means no time limit for this key)
$maxQueriesPerIPPerHour integer Specify the maximum number of API calls allowed from an IP address per hour. Defaults to 0 (no rate limit).
$maxHitsPerQuery integer Specify the maximum number of hits this API key can retrieve in one call. Defaults to 0 (unlimited)
$indexes array | null Specify the list of indices to target (null means all)
리턴 mixed

프로퍼티 상세

$caInfoPath 보호되어 있는 프로퍼티

protected string $caInfoPath
리턴 string

$context 보호되어 있는 프로퍼티

protected ClientContext,algoliasearch $context
리턴 ClientContext

$curlConstants 보호되어 있는 프로퍼티

protected array $curlConstants
리턴 array

$curlOptions 보호되어 있는 프로퍼티

protected array $curlOptions
리턴 array

$placesEnabled 보호되어 있는 프로퍼티

protected bool $placesEnabled
리턴 boolean