filippo-toso / travelport
Travelport SOAP API 的 PHP 客户端库
v19.2.4
2020-03-25 10:23 UTC
Requires
- php: ^7.1.3
- illuminate/support: ^5.6 || ^5.7 || ^5.8 || ^6.0 || ^7.0
README
使用这个库,您可以以面向对象的方式调用 Travelport SOAP 方法。
安装
您可以通过 composer 安装此包
composer require filippo-toso/travelport
使用方法
如果您没有所需的凭据,您可以在此页面上注册试用:https://developer.travelport.com/web/developer/contact-us?type=UAPI
以下是一个纯 PHP 示例
use FilippoToso\Travelport; use FilippoToso\Travelport\System; // Create the API client $travelport = new Travelport\Travelport( 'Universal API/uAPI123456789', // Travelport User ID 'ABCDEFGHILMNOQRSTUVZ', // Travelport Password 'P1234567', // Travelport Target Branch Travelport\Endpoints::REGION_EMEA, // Region false // Set to false to use pre-production endpoints ); // Create a Time request on the System service $request = (new System\TimeReq()) ->setBillingPointOfSaleInfo(new System\BillingPointOfSaleInfo('UAPI')); // Don't know what this is, but it's required to complete a call :( // Execute the request $response = $travelport->execute($request); printf('The current system time is %s', $response->getSystemTime()); // Create a Ping request on the System service $request = (new System\PingReq()) ->setPayload('Hello World!') ->setBillingPointOfSaleInfo(new System\BillingPointOfSaleInfo('UAPI')); // Don't know what this is, but it's required to complete a call :( // Execute the request $response = $travelport->execute($request); printf('Travelport pinged back: %s', $response->getPayload());
此库支持几乎所有可用的请求和响应。它们可以以相同的方式执行
- 创建响应对象
- 执行请求
- 使用答案中的方法获取您所需的信息
您可以通过浏览库源代码来了解哪些方法可用。通常,请求对象名称以 "Req" 结尾,相应的响应以 "Rsp" 结尾(例如,System\TimeReq 和 System\TimeRsp)。
Laravel 支持
您还可以在 Laravel 应用中使用此库。
第一步是发布配置文件
php artisan vendor:publish --tag=config --provider="FilippoToso\Travelport\TravelportServiceProvider"
然后在 config\travelport.php 文件中插入您的凭据。
然后您可以使用类似以下代码执行请求
use FilippoToso\Travelport; use FilippoToso\Travelport\System; // Create a Time request on the System service $request = (new System\TimeReq()) ->setBillingPointOfSaleInfo(new System\BillingPointOfSaleInfo('UAPI')); // Don't know what this is, but it's required to complete a call :( // Execute the request $response = Travelport::execute($request); printf('The current system time is %s', $response->getSystemTime()); // Create a Ping request on the System service $request = (new System\PingReq()) ->setPayload('Hello World!') ->setBillingPointOfSaleInfo(new System\BillingPointOfSaleInfo('UAPI')); // Don't know what this is, but it's required to complete a call :( // Execute the request $response = Travelport::execute($request); printf('Travelport pinged back: %s', $response->getPayload());
架构版本
此库当前支持 19.2 架构版本。我希望每年至少更新一次。
变更日志
有关最近更改的更多信息,请参阅 CHANGELOG
安全
如果您发现任何安全相关的问题,请通过电子邮件 filippo@toso.dev 反馈,而不是使用问题跟踪器。
致谢
许可证
MIT 许可证(MIT)。有关更多信息,请参阅 许可证文件