iansltx / joind-in-client
为 joind.in 提供的基于 Guzzle 的 API 客户端
dev-master / 1.0.x-dev
2017-11-13 23:20 UTC
Requires
- php: >=7.1
- guzzlehttp/guzzle: ^6.3
This package is auto-updated.
Last update: 2024-09-06 17:51:30 UTC
README
这是一个基于 Guzzle 的 joind.in API 客户端。请注意,这个 README 是有效的 PHP 代码,因此您可以运行它来查看库的实际效果(这就是为什么有 ?> 标签)。
开始之前,请运行 composer require iansltx/joind-in-client
。然后
<?php require __DIR__ . '/vendor/autoload.php'; // sets up a client with default params; // the underlying constructor takes a Guzzle ClientInterface for easier testing $client = \iansltx\JoindInClient\Client::create(); $schedule = $client->getScheduleByEventId(6476); // pull the php[world] schedule ?>
计划是一个实现了 Countable 和 read-only ArrayAccess 的事件集合,还包含一些方便的方法,包含 Event 对象。事件实现了 __toString() 和 jsonSerialize() 方法。两者都返回适合显示的字符串,所以如果您想在您的 JSON blob 中包含更多数据,您需要手动从每个 Event 中提取数据。
<?php
date_default_timezone_set('America/New_York');
print("Next up: " . $schedule->filterOutBefore(new \DateTimeImmutable('2017-11-14 09:55:55'))[5] . ".\n");
?>