edwardcrompton / porthtermau
Porth Termau服务的API包装器
dev-main
2020-12-24 14:52 UTC
Requires
- paquettg/php-html-parser: ^2.0
Requires (Dev)
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2024-09-24 22:47:21 UTC
README
这是一个PorthTermau API的PHP包装器。
https://www.bangor.ac.uk/cymorthcymraeg/porth_termau.php.cy
使用API需要Bangor大学签发的API密钥。
目前还在进行中,后续将有更多文档。
使用composer安装
composer require edwardcrompton/porthtermau:dev-main
从git克隆并安装
git clone git@github.com:edwardcrompton/porthtermau.git
cd porthtermau
composer install
运行phpunit测试
./vendor/bin/phpunit tests
用法
include('src/PorthTermauWrapper.php');
$api = new PorthTermau\PorthTermauWrapper(
['key' => 'secret key', 'referer' => 'http://llennatur.cymru']
);
// Look up a term
$term = $api->lookup('Vulpes vulpes');
// Translate the term to Cymraeg
$cyTerm = $term->translate('cy');
// Translate the term to English
$enTerm = $term->translate('en');
// Get the Url of the term in cy.wikipedia.org.
$url = $term->getUrl();
// Get an thumbnail image URL for the term
$img = $term->getImageThumb();