saracubillas / flight-aware-php-client
非常简单的FlightAware API的PHP客户端
v0.0.8
2024-08-06 13:14 UTC
Requires
- php: ^7.4 || ^8.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^6.3 || ^7.0
- guzzlehttp/psr7: ^1.5 || ^2.0
README
介绍 AeroAPI是一个简单的基于查询的API,为软件开发者提供访问FlightAware各种飞行数据的方式。用户可以获取当前或历史数据。AeroAPI是一个提供准确和可操作航空数据的RESTful API。随着Foresight™的引入,客户可以访问支撑美国一半预测性航班预计时间的飞行数据。## 分类 AeroAPI被划分为几个类别,以简化数据的查找。 - 飞行:总结信息、计划航线、位置等 - Foresight:增强FlightAware Foresight™的飞行位置 - 机场:机场信息和FIDS风格的资源 - 运营商:运营商信息和机队活动资源 - 警报:配置航班警报和交付目的地 - 历史:各种端点的历史飞行数据 - 其他:飞行中断、未来计划信息、飞机拥有者信息## 开发工具 AeroAPI使用OpenAPI Spec 3.0定义,这意味着它可以轻松导入到Postman等工具。要开始,请尝试使用Postman的说明导入API规范。一旦导入为集合,仅需要在集合的“授权”选项卡下填写“值”字段并保存,然后在调用之前。AeroAPI OpenAPI规范位于:https://flightaware.com/commercial/aeroapi/resources/aeroapi-openapi.yml我们的开源AeroApps项目提供了一些服务和示例应用程序,以帮助您开始。飞行信息显示系统(FIDS)AeroApp是一个使用多种语言和Docker容器构建的多层应用的示例。它展示了连接性、数据缓存、航班展示和利用飞行地图。警报AeroApp展示了在具有Docker化Python后端和React前端示例应用程序中使用AeroAPI设置、编辑和接收警报的方法。我们的AeroAPI推送通知测试接口提供了一个快速简单的方式来测试通过AeroAPI推送定制警报的交付。
- API版本:4.12
- 包版本:1
要求
PHP 5.5及更高版本
安装与使用
Composer
要使用Composer安装绑定,请将以下内容添加到composer.json
{
"repositories": [
{
"type": "git",
"url": "https://github.com/saracubillas/flight-aware-php-client.git"
}
],
"require": {
"saracubillas/flight-aware-php-client": "*@dev"
}
}
然后运行composer install
手动安装
下载文件并包含autoload.php
require_once('/path/to/FlightAwarePHPClient/vendor/autoload.php');
测试
要运行单元测试
composer install
./vendor/bin/phpunit
入门
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: ApiKeyAuth
$config = FlightAware\PHPClient\Configuration::getDefaultConfiguration()->setApiKey('x-apikey', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = FlightAware\PHPClient\Configuration::getDefaultConfiguration()->setApiKeyPrefix('x-apikey', 'Bearer');
$apiInstance = new FlightAware\PHPClient\FlightAwarePHPClient\FlightsApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(),
$config
);
$ident = "ident_example"; // string | The ident, registration, or fa_flight_id to fetch
$ident_type = "ident_type_example"; // string | Type of ident provided in the ident parameter. By default, the passed ident is interpreted as a registration if possible. This parameter can force the ident to be interpreted as a designator instead.
$start = new \FlightAware\PHPClient\Model\Start(); // \FlightAware\PHPClient\Model\Start | The starting date range for flight results, comparing against flights' `scheduled_out` field (or `scheduled_off` if `scheduled_out` is missing). The format is ISO8601 date or datetime, and the bound is inclusive. Specified start date must be no further than 10 days in the past and 2 days in the future. If not specified, will default to departures starting approximately 11 days in the past. If using date instead of datetime, the time will default to 00:00:00Z.
$end = new \FlightAware\PHPClient\Model\End(); // \FlightAware\PHPClient\Model\End | The ending date range for flight results, comparing against flights' `scheduled_out` field (or `scheduled_off` if `scheduled_out` is missing). The format is ISO8601 date or datetime, and the bound is exclusive. Specified end date must be no further than 10 days in the past and 2 days in the future. If not specified, will default to departures starting approximately 2 days in the future. If using date instead of datetime, the time will default to 00:00:00Z.
$max_pages = 1; // int | Maximum number of pages to fetch. This is an upper limit and not a guarantee of how many pages will be returned.
$cursor = "cursor_example"; // string | Opaque value used to get the next batch of data from a paged collection.
try {
$result = $apiInstance->getFlight($ident, $ident_type, $start, $end, $max_pages, $cursor);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling FlightsApi->getFlight: ', $e->getMessage(), PHP_EOL;
}
?>
授权文档
ApiKeyAuth
- 类型:API密钥
- API密钥参数名称:x-apikey
- 位置:HTTP头