定制 mettleworks/big-huge-thesaurus-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mettleworks/big-huge-thesaurus-client

Composer 安装命令:

composer require mettleworks/big-huge-thesaurus-client

包简介

PHP Client around Big Huge Thesaurus API

README 文档

README

Latest Version on Packagist Software License Total Downloads

PHP Wrapper for the Big Huge Labs Thesaurus API.

Install

Via Composer

$ composer require mettle/big-huge-thesaurus-client

Usage

$API_KEY = 'Get an api key @ https://words.bighugelabs.com/api.php';

$client = new Mettleworks\BigHugeThesaurusClient\BigHugeThesaurusClient($API_KEY);
$response = $client->lookup('love');

The response object is an instance of ThesaurusResponse, an object that wraps the original response and adds a few convenience methods. You can optionally pass an argument to each method to indicate if you want only nouns (noun), verbs (verb), adjectives (adjective) or adverbs (adverb) otherwise they will return all results combined. The signature of the methods is the following:

/**
 * Get the synonyms from the response
 */
$response->getSynonyms($type = null): array

/**
 * Get the antonyms from the response
 */
$response->getAntonyms($type = null): array

/**
 * Get the similar terms from the response
 */
$response->getSimilarTerms($type = null): array

/**
 * Get related terms from the response
 */
$response->getRelatedTerms($type = null): array

/**
 * Cast response to array (returns the original response)
 */ 
$response->toArray(): array

/**
 * Cast response to JSON
 */
$response->toJson()

The client throws specific exceptions when an error occurs. Those errors are documented on the Big Huge Thesaurus Api Page.

try {
    $response = $client->lookup('love');
} catch (NotFoundException $ex) {
    // Not Found
} catch (UsageExceededException $ex) {
    // Usage exceeded
} catch (InactiveKeyException $ex) {
    // Key not active
} catch (MissingWordsException $ex) {
    // No words provided
} catch (NotWhitelistedException $ex) {
    // IP address blocked
}

Additionally if an error occurs outside the listed ones, the original Guzzle Exception is thrown.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email maurizio@mettle.io instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 960
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 4
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固