titravel/api-sdk-php

为岛际旅行的API提供的PHP SDK

v0.2.14 2022-10-13 07:04 UTC

README

Latest Stable Version Total Downloads

此存储库包含岛际旅行的PHP SDK以及API的示例代码

先决条件

  • PHP 5.3或更高版本
  • 必须启用curl扩展
  • 必须启用json扩展
  • 使用composer获取依赖项(见https://getcomposer.org.cn

示例

用法

编写使用SDK的应用程序

  • titravel/api-sdk-php添加到您的composer.json的require列表中,或将sample/composer.json复制到项目根目录
  • 运行composer update --no-dev以获取依赖项
  • 岛际旅行获取API凭证
  • 现在您可以开始进行第一次API调用了
$apiCredentials = new \TiTravel\Auth\Credentials($config['b2b'], $config['code']);

try {
    $params = array(
        'city_id' => null,
        'category_id' => null,
    );
    $properties = PropertiesInfo::all($params, $apiCredentials);
} catch (Exception $ex) {
    echo 'Exception:', $ex->getMessage(), PHP_EOL;
    exit(1);
}

print_r($properties->toArray());