alexjustesen / php-untappd

Untappd非官方PHP SDK

v0.1.0 2023-03-19 20:03 UTC

This package is not auto-updated.

Last update: 2024-09-17 01:35:12 UTC


README

非官方UntappdAPI的PHP SDK。

赞助商

喜欢这个包吗?考虑赞助我以帮助我达成目标。

安装

composer require alexjustesen/php-untappd

使用方法

身份验证

Untappd API使用基于令牌的身份验证,您可以使用客户端ID和密钥或使用SSO用户的令牌生成令牌。

初始化请求

要开始,请创建SDK的新实例。

$untappd = new Untappd();

处理响应

SDK使用了Sam Carre的Saloon,在发送请求后,您可以使用文档中记录的任何方法与响应交互,如->body()->json()

在下面的示例中,我们请求一款啤酒并将响应格式化为json。

$request = new GetBeer('beer-id-goes-here');

$response = $untappd->send($request);

$response->json();

获取啤酒

$request = new GetBeer('beer-id-goes-here');

$response = $untappd->send($request);

搜索啤酒

$request = new SearchBeer('brewery name or beer name string');

$response = $untappd->send($request);

测试

使用PHP CS Fixer

composer fix-code

使用Pest

composer test