joel-depiltech / codeigniter-holidayapi
CodeIgniter第三方库,基于官方PHP库处理假日API
1.1.0
2017-12-22 14:16 UTC
Requires
- php: >=5.3.0
- composer/installers: ^1.4
- joshtronic/php-holidayapi: ^1.0
This package is not auto-updated.
Last update: 2024-09-15 04:31:30 UTC
README
CodeIgniter 第三方库,基于 假日API,基于 官方PHP库。
安装
注意,以下步骤假设您已正确安装Composer并在服务器上配置了CodeIgniter。
请使用 Composer 安装它,并将其作为第三方 包 包含在您的CodeIgniter应用程序中。
composer require joel-depiltech/codeigniter-holidayapi
- 确保您已在配置文件(application/config/config.php)中使用了Composer自动加载器
$config['composer_autoload'] = TRUE; // or a custom path as 'vendor/autoload.php'
- 使用Loader库包含此 包
$this->load->add_package_path(APPPATH . 'third_party/holidayapi');
- 使用Loader库包含此 库
$this->load->library('HolidayAPI');
- 在配置文件(config/holidayapi.php)中配置您的 API密钥
$config['holidayapi_test_api_key'] = '058f4506-caf0-4bdd-b52b-cbc98e20e02e'; $config['holidayapi_live_api_key'] = '*** Fill in your own Live API key ***';
使用方法
简单调用
默认情况下,获取美国的今年所有假日
<?php $this->load->library('HolidayAPI'); $holidays = $this->holidayapi->holidays(); print_r($holidays);
完整调用
一个示例,用于使用特定API密钥获取从圣诞节到2018年末的法国所有即将到来的假日
<?php $this->load->library('HolidayAPI', array('holidayapi_live_api_key' => '** An other API key **')); $holidays = $this->holidayapi->holidays('FR', 2018, 12, 25, FALSE, TRUE); print_r($holidays);