mvaessen/binance-api

简单的Binance API包装器,用PHP编写。包含基本功能和假设您熟悉这些功能。

0.2.4 2019-03-15 15:59 UTC

This package is not auto-updated.

Last update: 2024-09-21 19:22:43 UTC


README

简单的Binance API包装器,用PHP编写。包含一些基本方法来处理API,并假设您熟悉这些功能。有关可用端点的更多信息,请查看Binance API文档。遇到错误时将抛出异常。

请注意

  • 不包含拦截速率限制的机制。
  • 没有任何支持。
  • 自行承担风险。

入门

composer require mvaessen/binance-api

require 'vendor/autoload.php';
$api = new Mvaessen\BinanceApi\Client('<api key>','<secret>');

获取账户信息

$result = $api->account();
print $result;
公共端点调用
$result = $api->queryPublic('<method>', '<endpoint>', '<request>');
私有端点调用
$result = $api->queryPrivate('<method>', '<endpoint>', '<request>');

自定义错误报告

您可以选择重写processErrorCodeprocessException方法,将错误报告给您的首选错误报告软件。

<?php
namespace App;

use Mvaessen\BinanceApi\BinanceApiException;
use Mvaessen\BinanceApi\Client;

class BinanceApi extends Client
{
   protected function processErrorCode($response, $method, $url, $request)
   {
       //todo report to bugtracking software

       throw new BinanceApiException($response['msg']);
   }
   
   protected function processException($e, $method, $url, $request)
   {
       //todo report to bugtracking software

       throw new BinanceApiException($e->getMessage());
   }
}