searchili / searchili-client-php
SearChili搜索服务的客户端
1.1
2020-12-20 16:24 UTC
Requires
- php: >=5.6
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^6.0
README
SearChili API的PHP客户端
需求
- PHP 5.6+
- 与PSR-4兼容的自动加载器
- PHP必须使用lib-curl编译
安装
要安装库,只需通过composer添加
composer require SearChili/searchili-client-php
或在composer.json中
{ "SearChili/searchili-client-php": "^1.0" }
测试
我们可以使用composer运行测试
composer test
如何使用
要使用此库,您必须首先在SearChili上注册。注册后,将提供apiKey和apiSecret以访问API。
可以调用的API方法
- 站点信息
- 实体搜索
- 实体sayt
- 实体store
- 实体delete
以下是如何使用此库的示例。
Alice
搜索
<?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
获取认证的站点信息
<?php require_once "vendor/autoload.php"; use SearChili\Bob\Client as SearChiliBobClient; $client = new SearChiliBobClient('<apiSecret>'); $response = $client->site->get(); print_r($response->toArray());
存储
$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);
删除
$result = $aliceClient->entity->delete(1); var_dump($result);
许可证
此库遵循MIT的使用条款