tonolucro/delivery-merchant-php

与Tonolucro Merchant API集成的库

v1.0.0 2018-10-13 01:10 UTC

This package is auto-updated.

Last update: 2024-09-15 11:36:42 UTC


README

与Tonolucro Merchant API集成的PHP库

依赖关系

  • PHP >= 5.6

安装SDK

如果您的项目中已经存在composer.json文件,只需将以下依赖项添加到项目中

{
    "require": {
        "tonolucro/delivery-merchant-php": "^1.0"
    }
}

添加依赖项到composer.json后,只需执行以下命令

composer install

或者,您可以直接在终端中执行

composer require tonolucro/delivery-merchant-php

API文档

完整的API文档可在以下链接中找到:https://developers.tonolucro.com/

使用SDK

要使用SDK消费API资源,只需做以下操作

认证用户的企业信息

GET ​https://api.[sandbox.]tonolucro.com/v1/merchant/​info
<?php
require_once 'vendor/autoload.php';

use \Tonolucro\Delivery\Merchant\Http\Auth;
use \Tonolucro\Delivery\Merchant\Http\Environment;
use \Tonolucro\Delivery\Merchant\Merchant;

try{

    /**
     * Factory dos recursos da API
     */
    $manager = new Merchant(
        new Auth(
            'XXX' //Ver https://developers.tonolucro.com/merchant/autenticacao
        ),
        new Environment\Sandbox() //new Environment\Production()
    );

    /**
     * Instância do recurso /Merchant
     */
    $resource = $manager->getMerchantResource();

    /**
     * Método: https://developers.tonolucro.com/merchant/merchant#informacoes
     */
    $data = $resource->getInfo();

    /**
     * Navegue no array de informações.
     * Documentação: https://developers.tonolucro.com/merchant/objetos#merchant
     */
    print_r($data);

}catch (Exception $ex){
    die($ex->getMessage());
}

在目录/examles中查看其他使用示例。