alanly/picnik

一个现代的、与Composer和PSR-4兼容的PHP库,用于与Wordnik API接口。

v0.1.5 2015-01-06 22:11 UTC

This package is not auto-updated.

Last update: 2024-09-24 01:56:26 UTC


README

Picnik 是一个简单的PHP客户端,用于Wordnik API,与Composer和PSR-4兼容。

它的唯一依赖项是GuzzleHttp客户端和PHP >= 5.4。

API 覆盖范围

初始目标是支持 word 选择方法。

目前,实现了 /word.json/{word}/word.json/{word}/definitions API方法。

使用方法

为了使用客户端,您首先需要从 Wordnik 获取一个API密钥。

客户端的使用非常简单,

$client = new Picnik\Client;
$client->setApiKey('foobar');

$definitions = $client->wordDefinitions('cat')
                      ->limit(1)
                      ->includeRelated(false)
                      ->useCanonical(true)
                      ->get();

var_dump( count($definitions) );
// int(1)

var_dump( $definitions[0]->text )
// string(189) "A small carnivorous mammal (Felis catus or F. domesticus)
// domesticated since early times as a catcher of rats and mice and as a pet
// and existing in several distinctive breeds and varieties."

许可证

此库采用MIT许可证发布。有关详细信息,您可以参考完整的许可证文档