basebuy/basebuy-sdk-php

BasebuyAutoApi 的包装器

1.0.0 2017-08-09 22:18 UTC

This package is not auto-updated.

Last update: 2024-09-12 00:59:48 UTC


README

要求

PHP 5.3 或更高版本

链接

  1. BaseBuy.Auto API 页面:Ru,
  2. 示例应用

入门

安装

  1. 将仓库克隆到您的项目中。
  2. 粘贴以下代码
    require_once '/path/to/cloned/repo/BasebuyAutoApi.php';
    

使用 BaseBuy.Auto API 需要以下步骤

  1. http://basebuy.ru 购买数据库以获取 API_KEY(令牌)。注意:API_KEY 是您用于访问 BaseBuy.Auto API 的常量。

  2. 之后您就可以使用 BaseBuy.Auto API。

    $basebuyAutoApi = new BasebuyAutoApi(
        new CurlGetConnector( API_KEY )
    );
    
    // check last information update date
    $basebuyAutoApi->typeGetDateUpdate();
    
    // get database file
    $downloadedFilePath = $basebuyAutoApi->typeGetAll();
    
    // catch error codes
    } catch( Exception $e ){
        if ( $e->getCode() == 401 ) ...
    }
    

备注

  1. 在以下情况下库会抛出异常

    * response status isn't equal 2**
    * I/O error(see [requests](https://github.com/rmccue/Requests))
    

运行测试

  1. 克隆此仓库。
  2. 安装 composer
  3. 运行 composer install
  4. 创建包含 API_KEY 常量的 sample.php 文件。
  5. 运行它