定制 myallocator/myallocator-php-sdk-ota 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

myallocator/myallocator-php-sdk-ota

Composer 安装命令:

composer require myallocator/myallocator-php-sdk-ota

包简介

PHP SDK for OTA's to easily integrate with the MyAllocator OTA BuildToUs API

README 文档

README

MyAllocator BuildToUs API PHP SDK (JSON). Online Travel Agencies (OTA's) may use this SDK to quickly and reliably integrate with the MyAllocator BuildToUs API to enable distribution into their systems.

The MyAllocator BuildToUs API supports many OTA-inbound API's but only one OTA-outbound API (NotifyBooking). As a result, this SDK currently only implements the OTA-inbound API's defined in the MyAllocator BuildToUs API Documentation. You may implement the simple HTTP GET NotifyBooking API directly in your code base.

Note, this is not the PMS PHP SDK for PMS's. The PMS PHP SDK can be found at https://github.com/MyAllocator/myallocator-pms-php

MyAllocator BuildToUs API Version: 201503

MyAllocator BuildToUs API Documentation & Integration Guide [TODO]

MyAllocator BuildToUs API PHP SDK Documentation [http://myallocator.github.io/myallocator-ota-php-docs/]

MyAllocator [https://www.myallocator.com/]

MyAllocator Development Support [devhelp@myallocator.com]

Requirements

PHP 5.3.2 and later.

Documentation

Please see http://myallocator.github.io/myallocator-ota-php-docs/ for the complete and up-to-date SDK documentation.

Composer Installation

You can install via composer. Add the following to your project's composer.json.

{
    "require": {
        "myallocator/myallocator-php-sdk-ota": "1.*"
    }
}

Then install via:

composer.phar install

To use the bindings, either use Composer's autoload [https://getcomposer.org/doc/00-intro.md#autoloading]:

require_once('vendor/autoload.php');

Or manually:

require_once('/path/to/vendor/MyAllocator/myallocator-php-sdk-ota/src/MyAllocator.php');

Manual Installation

Grab the latest version of the SDK:

git clone https://github.com/MyAllocator/myallocator-ota-php.git

To use the bindings, add the following to a PHP script:

require_once('/path/to/myallocator-ota-php/src/MyAllocator.php');

Getting Started

Installation and usage example with composer installation:

root@nate:/var/www# mkdir test
root@nate:/var/www# cd test/
root@nate:/var/www/test# echo '{"require": {"myallocator/myallocator-php-sdk-ota": "1.*"}}' > composer.json
root@nate:/var/www/test# composer install
Loading composer repositories with package information
Installing dependencies (including require-dev)
  - Installing myallocator/myallocator-php-sdk-ota (1.0.0)
    Downloading: 100%         
Writing lock file
Generating autoload files
root@nate:/var/www/test# cp vendor/myallocator/myallocator-php-sdk-ota/examples/Receiver/* .

Configure your host's webserver at the desired endpoint to point to /var/www/test/MaReceiver.php. Send in a health check :)

root@nate:/var/www/test# curl -v -H "Accept: application/json" -X POST -H "Content-Type: application/json" -d '{"verb":"HealthCheck", "mya_property_id":"123", "ota_property_id":"321", "shared_secret":"test"}' http://{your_ip}:{your_port}/
{"success":true,"errors":null}

Installation and usage example with manual installation:

root@nate:/var/www# mkdir -p test/lib
root@nate:/var/www# cd test/lib/
root@nate:/var/www/test/lib# git clone https://github.com/MyAllocator/myallocator-ota-php.git
Cloning into 'myallocator-ota-php'...
remote: Counting objects: 111, done.
remote: Compressing objects: 100% (72/72), done.
remote: Total 111 (delta 38), reused 101 (delta 31), pack-reused 0
Receiving objects: 100% (111/111), 38.22 KiB | 0 bytes/s, done.
Resolving deltas: 100% (38/38), done.
Checking connectivity... done.
root@nate:/var/www/test/lib# cd ..
root@nate:/var/www/test# cp lib/myallocator-ota-php/examples/Receiver/* .

Edit require_once autoload in line 12 to:

require_once(dirname(__FILE__) . '/lib/myallocator-ota-php/src/MyAllocator.php');

Configure your host's webserver at the desired endpoint to point to /var/www/test/MaReceiver.php. Send in a health check :)

root@nate:/var/www/test# curl -v -H "Accept: application/json" -X POST -H "Content-Type: application/json" -d '{"verb":"HealthCheck", "mya_property_id":"123", "ota_property_id":"321", "shared_secret":"test"}' http://{your_ip}:{your_port}/
{"success":true,"errors":null}

Configuration

The default configuration file can be found at at src/MyAllocator/Config/MaConfig.php. The following is configurable:

shared_secret

The shared_secret will be allocated to the OTA by MyAllocator after initial registration. The shared_secret is used to authenticate the MA <-> OTA communication.

debugsEnabled

Set debugsEnabled to true in src/MyAllocator/Config/Config.php to display request and response data in the SDK interface and API transfer data formats for an API request.

Integration

This SDK is meant to be installed in the OTA's environment to act as an inbound API receiver for MyAllocator. It is not required for BuildToUs API integration, however, if an OTA is integrating via PHP we highly recommend utilizing the SDK to minimize integration time and costs.

The SDK consists of three primary parts: the receiver, SDK library, and backend interface (to be implemented by OTA).

Receiver

The receiver is located at examples/Receiver/MaReceiver.php and is the actual endpoint script that receives the request and forwards to the SDK library. It is optional for an OTA to utilize this receiver. If you have an existing framework for exposing endpoints, please feel free to continue using it and simply invoke the SDK library similar to the receiver example. If an existing mechanism is not available and you would like a quick solution, please feel free to use the included receiver.

SDK Library

The SDK library is located at src/MyAllocator and consists of the inbound API router, API definitions, backend interface definition, and required infrastructure.

Backend Interface

The SDK library includes a backend interface definition located at src/MyAllocator/Api/Inbound/MaInboundInterface.php which must be implemented by your environment so that the router (MaRouter.php) may forward requests to your backend system. You must instantiate an object of the class that implements this interface and pass it into the MaRouter object's construct during instantiation. Take a look at examples/Receiver/MaInboundInterfaceStub.php for a stub/example interface implementation and examples/Receiver/MaReceiver.php for how it is instantiated and passed into MaRouter.

It is worth explicitly noting, the backend interface implementations must return an MaResponse object to the calling router (as suggested by the docblocks).

Examples

Examples can be found in the examples/ directory.

Tests

You can run phpunit tests from the top directory:

vendor/bin/phpunit --debug

myallocator/myallocator-php-sdk-ota 适用场景与选型建议

myallocator/myallocator-php-sdk-ota 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 38.43k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 03 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「manager」 「myallocator」 「channel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 myallocator/myallocator-php-sdk-ota 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 myallocator/myallocator-php-sdk-ota 我们能提供哪些服务?
定制开发 / 二次开发

基于 myallocator/myallocator-php-sdk-ota 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 38.43k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 6
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-10