artstorm / monkeylearn-api
此包已被废弃且不再维护。未建议替代包。
MonkeyLearn API v2 客户端
0.5
2016-04-02 03:49 UTC
Requires
- php: >=5.4.0
- ext-curl: *
Requires (Dev)
- phpunit/phpunit: 4.*
- squizlabs/php_codesniffer: ~2.3
This package is not auto-updated.
Last update: 2020-01-24 15:51:36 UTC
README
一个易于使用的客户端,用于使用PHP消耗MonkeyLearn API v2。
安装
通过Composer
$ composer require artstorm/monkeylearn-api
要求
- PHP >= 5.4.0。
- PHP Curl。
MonkeyLearn API PHP客户端的基本用法
$token = 'monkeylearn-api-token'; $client = new Artstorm\MonkeyLearn\Client($token); $textToClassify = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'; $module = 'module_id'; $response = $client->classification->classify($textToClassify, $module); print_r($response->result());
调试和沙盒
MonkeyLearn有一个沙盒模式,可用于自定义模块。还有一个选项可以将调试数据包含在响应中。这些选项可以通过调用Client::sandbox()和Client::debug()方法启用。这些方法是可链式的。
$response = $client->sandbox()->classification->classify($text, $module); $response = $client->debug()->classification->classify($text, $module); $response = $client->sandbox()->debug()->classification->classify($text, $module);
查询限制
要找出MonkeyLearn API当前查询限制的信息,该信息可在响应对象中找到。
$response = $client->classification->classify($text, $module); $limits = $response->limits();
许可
此库是开源软件,许可协议为MIT许可证。