cryptomkt/cryptomkt-httplug-php

PHP客户端,用于将CryptoMarket集成到您的PHP项目中

0.1 2018-07-10 19:33 UTC

This package is not auto-updated.

Last update: 2024-09-12 01:09:55 UTC


README

官方客户端库 CryptoMarket API v1,用于使用HTTPlug客户端抽象 HTTPlug 将CryptoMarket集成到您的PHP项目中。

安装

可以使用Composer安装此库。请参阅Composer文档

"require": {
    "cryptomkt/cryptomkt-httplug-php": "dev-master"
}

身份验证

API密钥

使用API密钥和秘密来访问您的Crypto Market账户。

use Cryptomkt\Exchange\Client;
use Cryptomkt\Exchange\Configuration;

$configuration = Configuration::apiKey($apiKey, $apiSecret);
$client = Client::create($configuration);

警告

如果已配置,此库将所有警告记录到标准PSR-3日志记录器中。

use Cryptomkt\Exchange\Client;
use Cryptomkt\Exchange\Configuration;

$configuration = Configuration::apiKey($apiKey, $apiSecret);
$configuration->setLogger($logger);
$client = Client::create($configuration);

响应

每个资源对象都有一个getRawData()方法,您可以使用它访问未映射到对象属性的任何字段。

$data = $markets->getRawData();

最后HTTP响应的原始数据也可以在客户端对象中找到。

$data = $client->decodeLastResponse();

使用方法

有关更多参考资料,请访问官方文档

市场数据

列出市场

$markets = $client->getMarkets();

获取行情

$arguments = array('market' => 'ETHARS');
$ticker = $client->getTicker($arguments); 

获取交易

$arguments = array('market' => 'ETHCLP','start' => '2017-05-20', 'end' => '2017-05-30', 'page' => 1);
$trades = $client->getTrades($arguments);

订单

获取订单

$arguments = array('market' => 'ETHARS','type' => 'buy', 'page' => 1);
$orders = $client->getOrders($arguments); 

获取订单

$arguments = array('id' => 'M107435');
$order = $client->getOrder($arguments);  

获取活跃订单

$arguments = array('market' => 'ETHCLP', 'page' => 0);
$active_orders = $client->getActiveOrders($arguments); 

获取已执行订单

$arguments = array('market' => 'ETHCLP', 'page' => 0);
var_dump($client->getExecutedOrders($arguments)); 

创建订单

$arguments = array(
        'amount' => '0.3',
        'market' => 'ethclp',
        'price' => '200000',
        'type' => 'sell'
    );
$response = $client->createOrder($arguments); 

取消订单

$arguments = array('id' => 'M107441');
$response = $client->cancelOrder($arguments); 

余额

获取余额

$response = $client->getBalance(); 

创建支付订单

$arguments = array(
    'to_receive' => '3000',
    'to_receive_currency' => 'CLP',
    'payment_receiver' => '[email protected]',
    'external_id' => '123456CM',
    'callback_url' => '',
    'error_url' => '',
    'success_url' => '',
    'refund_email' => '[email protected]'
);

$response = $client->createPayOrder($arguments);  

支付订单

获取支付订单

$arguments = array('id' => 'P13565');
$response = $client->getPayOrder($arguments);  

获取支付订单

$arguments = array('start_date' => '1/05/2018','end_date' => '31/05/2018');
$response = $client->getPayOrders($arguments);  

贡献和测试

测试套件是用PHPUnit构建的。通过运行phpunit命令来运行单元测试套件。

phpunit