westy92 / holiday-event-api
PHP官方假日和事件API
v1.0.1
2022-12-29 22:28 UTC
Requires
- php: ^8.0
- doctrine/annotations: ^2.0
- guzzlehttp/guzzle: ^7.5
- phpdocumentor/reflection-docblock: ^5.3
- symfony/property-info: ^5.4
- symfony/serializer: ^5.4
Requires (Dev)
- phpunit/phpunit: ^9.5
- vimeo/psalm: ^5.4
This package is auto-updated.
Last update: 2024-09-10 15:59:43 UTC
README
行业领先的PHP假日和事件API。超过5,000个假日和数千个描述。被全球领先公司信任。自2011年以来由开发者为开发者构建。
支持的PHP版本
假日和事件API的最新版本与所有当前支持的PHP 发布版 兼容。
身份验证
访问假日和事件API需要API密钥。您可以在此处免费获取一个,无需信用卡!请注意,免费计划有限制。要访问更多数据和进行更多请求,需要付费计划。
安装
推荐通过 Composer 安装假日和事件API。
composer require westy92/holiday-event-api
示例
try { // Get a FREE API key from https://apilayer.com/marketplace/checkiday-api#pricing $client = new Westy92\HolidayEventApi\Client('<your API key>'); // Get Events for a given Date $events = $client->getEvents( // These parameters are the defaults but can be specified: // date: 'today', // timezone: 'America/Chicago', // adult: false, ); $event = $events->events[0]; echo "Today is {$event->name}! Find more information at: {$event->url}." . PHP_EOL; echo "Rate limit remaining: {$events->rateLimit?->remainingMonth}/{$events->rateLimit?->limitMonth} (month)." . PHP_EOL; // Get Event Information $eventInfo = $client->getEventInfo( id: $event->id, // These parameters can be specified to calculate the range of eventInfo->Event->Occurrences // start: 2020, // end: 2030, ); $hashtags = implode(', ', $eventInfo->event->hashtags); echo "The Event's hashtags are {$hashtags}." . PHP_EOL; // Search for Events $query = "zucchini"; $search = $client->search( query: $query, // These parameters are the defaults but can be specified: // adult: false, ); $count = count($search->events); echo "Found {$count} events, including '{$search->events[0]->name}', that match the query '{$query}'." . PHP_EOL; } catch (\Exception $e) { echo $e; }
许可证
假日和事件API在MIT许可证(MIT)下提供。有关更多信息,请参阅许可证文件。